diff options
Diffstat (limited to 'runtime/doc/treesitter.txt')
-rw-r--r-- | runtime/doc/treesitter.txt | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 9f17b9fb54..bb0d435f4a 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -793,17 +793,17 @@ get_filetypes({lang}) *vim.treesitter.language.get_filetypes()* Get the filetypes associated with the parser named {lang}. Parameters: ~ - • {lang} string Name of parser + • {lang} (string) Name of parser Return: ~ string[] filetypes get_lang({filetype}) *vim.treesitter.language.get_lang()* Parameters: ~ - • {filetype} string + • {filetype} (string) Return: ~ - string|nil + (string|nil) inspect({lang}) *vim.treesitter.language.inspect()* Inspects the provided language. @@ -821,7 +821,7 @@ register({lang}, {filetype}) *vim.treesitter.language.register()* Register a parser named {lang} to be used for {filetype}(s). Parameters: ~ - • {lang} string Name of parser + • {lang} (string) Name of parser • {filetype} string|string[] Filetype(s) to associate with lang @@ -1051,7 +1051,9 @@ contents. To create a LanguageTree (parser object) for a given buffer and language, use: >lua - local parser = vim.treesitter.get_parser(bufnr, lang) + + local parser = vim.treesitter.get_parser(bufnr, lang) + < (where `bufnr=0` means current buffer). `lang` defaults to 'filetype'. @@ -1062,7 +1064,9 @@ it wants incremental updates. Whenever you need to access the current syntax tree, parse the buffer: >lua - local tree = parser:parse() + + local tree = parser:parse() + < This returns a table of immutable |treesitter-tree| objects representing @@ -1175,22 +1179,23 @@ LanguageTree:register_cbs({cbs}, {recursive}) Registers callbacks for the |LanguageTree|. Parameters: ~ - • {cbs} (table) An |nvim_buf_attach()|-like table argument with - the following handlers: - • `on_bytes` : see |nvim_buf_attach()|, but this will be called after the parsers callback. - • `on_changedtree` : a callback that will be called - every time the tree has syntactical changes. It will - be passed two arguments: a table of the ranges (as - node ranges) that changed and the changed tree. - • `on_child_added` : emitted when a child is added to - the tree. - • `on_child_removed` : emitted when a child is removed - from the tree. - • `on_detach` : emitted when the buffer is detached, see - |nvim_buf_detach_event|. Takes one argument, the - number of the buffer. - • {recursive?} boolean Apply callbacks recursively for all children. - Any new children will also inherit the callbacks. + • {cbs} (table) An |nvim_buf_attach()|-like table argument with + the following handlers: + • `on_bytes` : see |nvim_buf_attach()|, but this will be called after the parsers callback. + • `on_changedtree` : a callback that will be called every + time the tree has syntactical changes. It will be + passed two arguments: a table of the ranges (as node + ranges) that changed and the changed tree. + • `on_child_added` : emitted when a child is added to the + tree. + • `on_child_removed` : emitted when a child is removed + from the tree. + • `on_detach` : emitted when the buffer is detached, see + |nvim_buf_detach_event|. Takes one argument, the number + of the buffer. + • {recursive} (boolean|nil) Apply callbacks recursively for all + children. Any new children will also inherit the + callbacks. LanguageTree:source() *LanguageTree:source()* Returns the source content of the language tree (bufnr or string). |