diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-10-23 18:20:19 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2021-10-23 18:24:00 +0200 |
commit | 9dd371bb2e60be4818c5d8fcd84274a700495fd9 (patch) | |
tree | c659c94014cf482a98c98bd869308459c0df304c /runtime | |
parent | fa4b24072e13dc7303e896701f0bb6d0227caf0c (diff) | |
download | rneovim-9dd371bb2e60be4818c5d8fcd84274a700495fd9.tar.gz rneovim-9dd371bb2e60be4818c5d8fcd84274a700495fd9.tar.bz2 rneovim-9dd371bb2e60be4818c5d8fcd84274a700495fd9.zip |
feat(lua): document support of packages with v:lua syntax
this already worked in 0.5 but was not properly documented or tested
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/lua.txt | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index fe94e89e2a..877c838602 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -393,6 +393,14 @@ where the args are converted to Lua values. The expression > is equivalent to the Lua chunk > return somemod.func(...) +In addition, functions of packages can be accessed like > + v:lua.require'mypack'.func(arg1, arg2) + v:lua.require'mypack.submod'.func(arg1, arg2) +Note: only single quote form without parens is allowed. Using +`require"mypack"` or `require('mypack')` as prefixes do NOT work (the latter +is still valid as a function call of itself, in case require returns a useful +value). + The `v:lua` prefix may be used to call Lua functions as |method|s. For example: > arg1->v:lua.somemod.func(arg2) @@ -409,7 +417,8 @@ For example consider the following Lua omnifunc handler: > end vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.mymod.omnifunc') -Note: the module ("mymod" in the above example) must be a Lua global. +Note: the module ("mymod" in the above example) must either be a Lua global, +or use the require syntax as specified above to access it from a package. Note: `v:lua` without a call is not allowed in a Vimscript expression: |Funcref|s cannot represent Lua functions. The following are errors: > |