Home Explore Blog CI



neovim

24th chunk of `runtime/doc/treesitter.txt`
bfd13ca383dcf7a590ceaede2422e62dce09f43c9abffd230000000100000d5e
 (`boolean?`) whether to ignore the validity of
                            children (default `false`)
      • {range}             (`Range?`) range to check for validity

    Return: ~
        (`boolean`)

LanguageTree:lang()                                      *LanguageTree:lang()*
    Gets the language of this tree node.

    Return: ~
        (`string`)

                                           *LanguageTree:language_for_range()*
LanguageTree:language_for_range({range})
    Gets the appropriate language that contains {range}.

    Parameters: ~
      • {range}  (`table`) A table with the following fields:
                 • {[1]} (`integer`) start row
                 • {[2]} (`integer`) start column
                 • {[3]} (`integer`) end row
                 • {[4]} (`integer`) end column

    Return: ~
        (`vim.treesitter.LanguageTree`) tree Managing {range}

                                         *LanguageTree:named_node_for_range()*
LanguageTree:named_node_for_range({range}, {opts})
    Gets the smallest named node that contains {range}.

    Parameters: ~
      • {range}  (`table`) A table with the following fields:
                 • {[1]} (`integer`) start row
                 • {[2]} (`integer`) start column
                 • {[3]} (`integer`) end row
                 • {[4]} (`integer`) end column
      • {opts}   (`table?`) A table with the following fields:
                 • {ignore_injections}? (`boolean`, default: `true`) Ignore
                   injected languages

    Return: ~
        (`TSNode?`)

                                               *LanguageTree:node_for_range()*
LanguageTree:node_for_range({range}, {opts})
    Gets the smallest node that contains {range}.

    Parameters: ~
      • {range}  (`table`) A table with the following fields:
                 • {[1]} (`integer`) start row
                 • {[2]} (`integer`) start column
                 • {[3]} (`integer`) end row
                 • {[4]} (`integer`) end column
      • {opts}   (`table?`) A table with the following fields:
                 • {ignore_injections}? (`boolean`, default: `true`) Ignore
                   injected languages

    Return: ~
        (`TSNode?`)

LanguageTree:parent()                                  *LanguageTree:parent()*
    Returns the parent tree. `nil` for the root tree.

    Return: ~
        (`vim.treesitter.LanguageTree?`)

LanguageTree:parse({range}, {on_parse})                 *LanguageTree:parse()*
    Recursively parse all regions in the language tree using
    |treesitter-parsers| for the corresponding languages and run injection
    queries on the parsed trees to determine whether child trees should be
    created and parsed.

    Any region with empty range (`{}`, typically only the root tree) is always
    parsed; otherwise (typically injections) only if it intersects {range} (or
    if {range} is `true`).

    Parameters: ~
      • {range}     (`boolean|Range?`) Parse this range in the parser's
                    source. Set to `true` to run a complete parse of the
                    source (Note: Can be slow!) Set to `false|nil` to only
                    parse regions with empty ranges (typically only the root
                    tree without injections).
      • {on_parse}  (`fun(err?: string, trees?: table<integer, TSTree>)?`)
                    Function invoked

Title: LanguageTree Functions: Node Retrieval, Parent Access, and Parsing
Summary
This section details functions for retrieving nodes within a `LanguageTree`, accessing the parent tree, and parsing operations. `LanguageTree:named_node_for_range()` retrieves the smallest named node containing a specified range, while `LanguageTree:node_for_range()` retrieves the smallest node. `LanguageTree:parent()` returns the parent tree, or `nil` for the root. `LanguageTree:parse()` recursively parses regions, using treesitter-parsers and injection queries to create child trees.