diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-18 22:04:31 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-05-19 17:30:20 +0200 |
commit | e628c011bfb58685e4a4ce7da681afda08989a7f (patch) | |
tree | 451d33c6316d038acdba7f73d41bf1cda32fa211 /runtime | |
parent | 53576dfb3598244afba3dbf5b60e6113109bf7c6 (diff) | |
download | rneovim-e628c011bfb58685e4a4ce7da681afda08989a7f.tar.gz rneovim-e628c011bfb58685e4a4ce7da681afda08989a7f.tar.bz2 rneovim-e628c011bfb58685e4a4ce7da681afda08989a7f.zip |
gen_vimdoc.py: support lua/shared.lua module [ci skip]
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/if_lua.txt | 40 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 10 |
2 files changed, 36 insertions, 14 deletions
diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index 57f5da7cd0..32751de3a2 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -30,7 +30,7 @@ finds and loads Lua modules. The conventions are similar to VimL plugins, with some extra features. See |lua-require-example| for a walkthrough. ============================================================================== -Importing modules *lua-require* +Importing Lua modules *lua-require* Nvim automatically adjusts `package.path` and `package.cpath` according to effective 'runtimepath' value. Adjustment happens whenever 'runtimepath' is @@ -325,9 +325,10 @@ Examples: > Note that currently second argument to `luaeval` undergoes VimL to lua conversion, so changing containers in lua do not affect values in VimL. Return value is also always converted. When converting, |msgpack-special-dict|s are +treated specially. ============================================================================== -vim.* *lua-vim* *lua-stdlib* +Lua standard modules *lua-stdlib* The Nvim Lua "standard library" (stdlib) is the `vim` module, which exposes various functions and sub-modules. It is always loaded, thus require("vim") @@ -361,7 +362,7 @@ Note that underscore-prefixed functions (e.g. "_os_proc_children") are internal/private and must not be used by plugins. ------------------------------------------------------------------------------ -vim.api.* functions +VIM.API *lua-api* `vim.api` exposes the full Nvim |API| as a table of Lua functions. @@ -371,7 +372,7 @@ For example, to use the "nvim_get_current_line()" API function, call print(tostring(vim.api.nvim_get_current_line())) ------------------------------------------------------------------------------ -vim.* builtin functions +VIM *lua-util* vim.inspect({object}, {options}) *vim.inspect* Return a human-readable representation of the passed object. See @@ -419,7 +420,7 @@ vim.types *lua-vim.types* only contain values for these three types. ============================================================================== -Vim Lua Functions *lua-vim* +Lua module: vim *lua-vim* gsplit({s}, {sep}, {plain}) *vim.gsplit()* Split a string by a given separator. The separator can be a @@ -442,11 +443,12 @@ gsplit({s}, {sep}, {plain}) *vim.gsplit()* split({s}, {sep}, {plain}) *vim.split()* Split a string by a given separator. - Examples: + Examples: > - - split(":aa::b:", ":") returns {'','aa','','bb',''} - - split("axaby", "ab?") returns {'','x','y'} - - split(x*yz*o, "*", true) returns {'x','yz','o'} + split(":aa::b:", ":") --> {'','aa','','bb',''} + split("axaby", "ab?") --> {'','x','y'} + split(x*yz*o, "*", true) --> {'x','yz','o'} +< Parameters: ~ {s} String The string to split @@ -483,4 +485,24 @@ deepcopy({orig}) *vim.deepcopy()* A new table where the keys and values are deepcopies of the keys and values from the original table. + + + +tbl_contains({t}, {value}) *vim.tbl_contains()* + TODO: Documentation + +tbl_extend({behavior}, {...}) *vim.tbl_extend()* + Parameters: ~ + {behavior} Decides what to do if a key is found in more + than one map: + - "error": raise an error + - "keep": use value from the leftmost map + - "force": use value from the rightmost map + + See also: ~ + |extend()| + +tbl_flatten({t}) *vim.tbl_flatten()* + TODO: Documentation + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 9dca51ce9a..ec0c74e257 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -16,14 +16,14 @@ local function tbl_contains(t, value) return false end ---- Merges two or more map-like tables. +-- Merges two or more map-like tables. -- --@see |extend()| -- --- behavior: Decides what to do if a key is found in more than one map: --- "error": raise an error --- "keep": use value from the leftmost map --- "force": use value from the rightmost map +--@param behavior Decides what to do if a key is found in more than one map: +--- - "error": raise an error +--- - "keep": use value from the leftmost map +--- - "force": use value from the rightmost map local function tbl_extend(behavior, ...) if (behavior ~= 'error' and behavior ~= 'keep' and behavior ~= 'force') then error('invalid "behavior": '..tostring(behavior)) |