diff options
author | Thomas Vigouroux <thomas.vigouroux@protonmail.com> | 2022-09-07 08:39:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-07 08:39:56 +0200 |
commit | fd1595514b747d8b083f78007579d869ccfbe89c (patch) | |
tree | 41e52c9e43db9351de3aa33a8628b76db07906c3 /runtime/doc | |
parent | f32fd19f1eedbd75e6a37b73f28cf8761e0e875c (diff) | |
download | rneovim-fd1595514b747d8b083f78007579d869ccfbe89c.tar.gz rneovim-fd1595514b747d8b083f78007579d869ccfbe89c.tar.bz2 rneovim-fd1595514b747d8b083f78007579d869ccfbe89c.zip |
Use weak tables in tree-sitter code (#17117)
feat(treesitter): use weak tables when possible
Also add the defaulttable function to create a table whose values are created when a key is missing.
Diffstat (limited to 'runtime/doc')
-rw-r--r-- | runtime/doc/lua.txt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index a634cc1e93..35badb13b1 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1581,6 +1581,28 @@ deepcopy({orig}) *vim.deepcopy()* Return: ~ (table) Table of copied keys and (nested) values. +defaulttable({create}) *vim.defaulttable()* + Creates a table whose members are automatically created when accessed, if + they don't already exist. + + They mimic defaultdict in python. + + If `create` is `nil`, this will create a defaulttable whose constructor + function is this function, effectively allowing to create nested tables on + the fly: +> + + local a = vim.defaulttable() + a.b.c = 1 +< + + Parameters: ~ + {create} (function|nil) The function called to create a missing + value. + + Return: ~ + (table) Empty table with metamethod + endswith({s}, {suffix}) *vim.endswith()* Tests if `s` ends with `suffix`. |