diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-08-04 21:12:52 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-04 21:12:52 +0200 |
commit | 9dc4bef897a37a610a28d69cee6d30749db61296 (patch) | |
tree | 6a17977e373aa38cd1f30216a5f3739ceebaf183 /runtime | |
parent | 57942237c1d54d8a236b43c56dc2b002339eb394 (diff) |
patch 8.2.3288: cannot easily access namespace dictionaries from Luav8.2.3288
Problem: Cannot easily access namespace dictionaries from Lua.
Solution: Add vim.g, vim.b, etc. (Yegappan Lakshmanan, closes #8693,
from NeoVim)
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/if_lua.txt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index 48b42e65db..cb68eefe00 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -211,6 +211,38 @@ Vim evaluation and command execution, and others. vim.lua_version The Lua version Vim was compiled with, in the form {major}.{minor}.{patch}, e.g. "5.1.4". + *lua-vim-variables* +The Vim editor global dictionaries |g:| |w:| |b:| |t:| |v:| can be accessed +from Lua conveniently and idiomatically by referencing the `vim.*` Lua tables +described below. In this way you can easily read and modify global Vimscript +variables from Lua. + +Example: > + + vim.g.foo = 5 -- Set the g:foo Vimscript variable. + print(vim.g.foo) -- Get and print the g:foo Vimscript variable. + vim.g.foo = nil -- Delete (:unlet) the Vimscript variable. + +vim.g *vim.g* + Global (|g:|) editor variables. + Key with no value returns `nil`. + +vim.b *vim.b* + Buffer-scoped (|b:|) variables for the current buffer. + Invalid or unset key returns `nil`. + +vim.w *vim.w* + Window-scoped (|w:|) variables for the current window. + Invalid or unset key returns `nil`. + +vim.t *vim.t* + Tabpage-scoped (|t:|) variables for the current tabpage. + Invalid or unset key returns `nil`. + +vim.v *vim.v* + |v:| variables. + Invalid or unset key returns `nil`. + ============================================================================== 3. List userdata *lua-list* |