@@ -10,11 +10,12 @@ The Lua Interface to Vim *lua* *Lua*
10
10
2. The vim module | lua-vim |
11
11
3. List userdata | lua-list |
12
12
4. 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 |
18
19
19
20
{Vi does not have any of these commands}
20
21
@@ -140,6 +141,14 @@ Vim evaluation and command execution, and others.
140
141
:echo luaeval('vim.dict(t)')
141
142
:" {'1': 3.141593, '2': v:false,
142
143
:" '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
143
152
<
144
153
vim.funcref({name} ) Returns a Funcref to function {name} (see
145
154
| Funcref | ). It is equivalent to Vim's
@@ -260,7 +269,34 @@ Examples:
260
269
<
261
270
262
271
==============================================================================
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*
264
300
265
301
Funcref userdata represent funcref variables in Vim. Funcrefs that were
266
302
defined with a "dict" attribute need to be obtained as a dictionary key
@@ -293,7 +329,7 @@ Examples:
293
329
<
294
330
295
331
==============================================================================
296
- 6 . Buffer userdata *lua-buffer*
332
+ 7 . Buffer userdata *lua-buffer*
297
333
298
334
Buffer userdata represent vim buffers. A buffer userdata "b" has the following
299
335
properties and methods:
@@ -345,7 +381,7 @@ Examples:
345
381
<
346
382
347
383
==============================================================================
348
- 7 . Window userdata *lua-window*
384
+ 8 . Window userdata *lua-window*
349
385
350
386
Window objects represent vim windows. A window userdata "w" has the following
351
387
properties and methods:
@@ -377,7 +413,7 @@ Examples:
377
413
<
378
414
379
415
==============================================================================
380
- 8. The luaeval function *lua-luaeval* *lua-eval*
416
+ 9. luaeval() Vim function *lua-luaeval* *lua-eval*
381
417
382
418
The (dual) equivalent of "vim.eval" for passing Lua values to Vim is
383
419
"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:
390
426
end
391
427
<
392
428
Note 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.
397
433
398
434
Examples: >
399
435
@@ -408,7 +444,7 @@ Examples: >
408
444
409
445
410
446
==============================================================================
411
- 9 . Dynamic loading *lua-dynamic*
447
+ 10 . Dynamic loading *lua-dynamic*
412
448
413
449
On MS-Windows and Unix the Lua library can be loaded dynamically. The
414
450
| :version | output then includes | +lua/dyn | .
0 commit comments