diff options
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r-- | runtime/doc/lua.txt | 75 |
1 files changed, 65 insertions, 10 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 00126f668b..002fc523a1 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1031,6 +1031,9 @@ inspect({object}, {options}) *vim.inspect()* https://github.com/kikito/inspect.lua https://github.com/mpeterv/vinspect +make_meta_accessor({get}, {set}, {del}) *vim.make_meta_accessor()* + TODO: Documentation + paste({lines}, {phase}) *vim.paste()* Paste handler, invoked by |nvim_paste()| when a conforming UI (such as the |TUI|) pastes text into the editor. @@ -1146,7 +1149,7 @@ list_extend({dst}, {src}, {start}, {finish}) *vim.list_extend()* |vim.tbl_extend()| pesc({s}) *vim.pesc()* - Escapes magic chars in a Lua pattern string. + Escapes magic chars in a Lua pattern. Parameters: ~ {s} String to escape @@ -1190,8 +1193,7 @@ startswith({s}, {prefix}) *vim.startswith()* tbl_add_reverse_lookup({o}) *vim.tbl_add_reverse_lookup()* Add the reverse lookup values to an existing table. For - example: `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = - 1 }` + example: tbl_add_reverse_lookup { A = 1 } == { [1] = 'A , A = 1 }` Parameters: ~ {o} table The table to add the reverse to. @@ -1206,6 +1208,37 @@ tbl_contains({t}, {value}) *vim.tbl_contains()* Return: ~ true if `t` contains `value` +tbl_count({t}) *vim.tbl_count()* + Counts the number of non-nil values in table `t` . +> + + vim.tbl_count({ a=1, b=2 }) => 2 + vim.tbl_count({ 1, 2 }) => 2 +< + + Parameters: ~ + {t} Table + + Return: ~ + Number that is the number of the value in table + + See also: ~ + https://github.com/Tieske/Penlight/blob/master/lua/pl/tablex.lua + +tbl_deep_extend({behavior}, {...}) *vim.tbl_deep_extend()* + Merges recursively two or more map-like tables. + + 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 + {...} Two or more map-like tables. + + See also: ~ + |tbl_extend()| + tbl_extend({behavior}, {...}) *vim.tbl_extend()* Merges two or more map-like tables. @@ -1220,6 +1253,13 @@ tbl_extend({behavior}, {...}) *vim.tbl_extend()* See also: ~ |extend()| +tbl_filter({func}, {t}) *vim.tbl_filter()* + Filter a table using a predicate function + + Parameters: ~ + {func} function or callable table + {t} table + tbl_flatten({t}) *vim.tbl_flatten()* Creates a copy of a list-like table such that any nested tables are "unrolled" and appended to the result. @@ -1238,11 +1278,19 @@ tbl_isempty({t}) *vim.tbl_isempty()* Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua@paramt Table to check tbl_islist({t}) *vim.tbl_islist()* - Table + Determine whether a Lua table can be treated as an array. + + An empty table `{}` will default to being treated as an array. + Use `vim.emtpy_dict()` to create a table treated as an empty + dict. Empty tables returned by `rpcrequest()` and `vim.fn` + functions can be checked using this function whether they + represent empty API arrays and vimL lists. + + Parameters: ~ + {t} Table Return: ~ - true: A non-empty array, false: A non-empty table, nil: An - empty table + `true` if array-like table, else `false` . tbl_keys({t}) *vim.tbl_keys()* Return a list of all keys used in a table. However, the order @@ -1257,6 +1305,13 @@ tbl_keys({t}) *vim.tbl_keys()* See also: ~ Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua +tbl_map({func}, {t}) *vim.tbl_map()* + Apply a function to all values of a table. + + Parameters: ~ + {func} function or callable table + {t} table + tbl_values({t}) *vim.tbl_values()* Return a list of all values used in a table. However, the order of the return table of values is not guaranteed. @@ -1301,12 +1356,12 @@ validate({opt}) *vim.validate()* => NOP (success) < > - vim.validate{arg1={1, 'table'}} - => error('arg1: expected table, got number') + vim.validate{arg1={1, 'table'}} + => error('arg1: expected table, got number') < > - vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}} - => error('arg1: expected even number, got 3') + vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}} + => error('arg1: expected even number, got 3') < Parameters: ~ |