mirror of
https://github.com/neovim/neovim.git
synced 2025-10-20 08:41:55 +00:00
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.
This commit is contained in:
@@ -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`.
|
||||
|
||||
|
Reference in New Issue
Block a user