@@ -10,11 +10,12 @@ The Lua Interface to Vim *lua* *Lua*
10102. The vim module | lua-vim |
11113. List userdata | lua-list |
12124. Dict userdata | lua-dict |
13- 5. Funcref userdata | lua-funcref |
14- 6. Buffer userdata | lua-buffer |
15- 7. Window userdata | lua-window |
16- 8. The luaeval function | lua-luaeval |
17- 9. Dynamic loading | lua-dynamic |
13+ 5. Blob userdata | lua-blob |
14+ 6. Funcref userdata | lua-funcref |
15+ 7. Buffer userdata | lua-buffer |
16+ 8. Window userdata | lua-window |
17+ 9. luaeval() Vim function | lua-luaeval |
18+ 10. Dynamic loading | lua-dynamic |
1819
1920{Vi does not have any of these commands}
2021
@@ -140,6 +141,14 @@ Vim evaluation and command execution, and others.
140141 :echo luaeval('vim.dict(t)')
141142 :" {'1': 3.141593, '2': v:false,
142143 :" 'say': 'hi'}
144+ <
145+ vim.blob([arg] ) Returns an empty blob or, if "arg" is a Lua
146+ string, returns a blob b such that b is
147+ equivalent to "arg" as a byte string.
148+ Examples: >
149+ :lua s = "12ab\x00\x80\xfe\xff"
150+ :echo luaeval('vim.blob(s)')
151+ :" 0z31326162.0080FEFF
143152<
144153 vim.funcref({name} ) Returns a Funcref to function {name} (see
145154 | Funcref | ). It is equivalent to Vim's
@@ -260,7 +269,34 @@ Examples:
260269<
261270
262271==============================================================================
263- 5. Funcref userdata *lua-funcref*
272+ 5. Blob userdata *lua-blob*
273+
274+ Blob userdata represent vim blobs. A blob "b" has the following properties:
275+
276+ Properties
277+ ----------
278+ o "#b" is the length of blob "b", equivalent to "len(b)" in Vim.
279+ o "b[k]" returns the k-th item in "b"; "b" is zero-indexed, as in Vim.
280+ To modify the k-th item, simply do "b[k] = number"; in particular,
281+ "b[#b] = number" can append a byte to tail.
282+
283+ Methods
284+ -------
285+ o "b:add(bytes)" appends "bytes" to the end of "b".
286+
287+ Examples:
288+ >
289+ :let b = 0z001122
290+ :lua b = vim.eval('b') -- same 'b'
291+ :lua print(b, b[0], #b)
292+ :lua b[1] = 32
293+ :lua b[#b] = 0x33 -- append a byte to tail
294+ :lua b:add("\x80\x81\xfe\xff")
295+ :echo b
296+ <
297+
298+ ==============================================================================
299+ 6. Funcref userdata *lua-funcref*
264300
265301Funcref userdata represent funcref variables in Vim. Funcrefs that were
266302defined with a "dict" attribute need to be obtained as a dictionary key
@@ -293,7 +329,7 @@ Examples:
293329<
294330
295331==============================================================================
296- 6 . Buffer userdata *lua-buffer*
332+ 7 . Buffer userdata *lua-buffer*
297333
298334Buffer userdata represent vim buffers. A buffer userdata "b" has the following
299335properties and methods:
@@ -345,7 +381,7 @@ Examples:
345381<
346382
347383==============================================================================
348- 7 . Window userdata *lua-window*
384+ 8 . Window userdata *lua-window*
349385
350386Window objects represent vim windows. A window userdata "w" has the following
351387properties and methods:
@@ -377,7 +413,7 @@ Examples:
377413<
378414
379415==============================================================================
380- 8. The luaeval function *lua-luaeval* *lua-eval*
416+ 9. luaeval() Vim function *lua-luaeval* *lua-eval*
381417
382418The (dual) equivalent of "vim.eval" for passing Lua values to Vim is
383419"luaeval". "luaeval" takes an expression string and an optional argument and
@@ -390,10 +426,10 @@ returns the result of the expression. It is semantically equivalent in Lua to:
390426 end
391427<
392428Note that "_A" receives the argument to "luaeval". Lua numbers, strings, and
393- list, dict, and funcref userdata are converted to their Vim respective types,
394- while Lua booleans are converted to numbers. An error is thrown if conversion
395- of any of the remaining Lua types, including userdata other than lists, dicts,
396- and funcrefs, is attempted.
429+ list, dict, blob, and funcref userdata are converted to their Vim respective
430+ types, while Lua booleans are converted to numbers. An error is thrown if
431+ conversion of any of the remaining Lua types, including userdata other than
432+ lists, dicts, blobs, and funcrefs, is attempted.
397433
398434Examples: >
399435
@@ -408,7 +444,7 @@ Examples: >
408444
409445
410446==============================================================================
411- 9 . Dynamic loading *lua-dynamic*
447+ 10 . Dynamic loading *lua-dynamic*
412448
413449On MS-Windows and Unix the Lua library can be loaded dynamically. The
414450| :version | output then includes | +lua/dyn | .
0 commit comments