tags
• PHP files, which can contain HTML between the `<php` tags
• JavaScript files, which contain regular expression syntax within regex
literals
• Ruby, which can contain snippets of code inside of heredoc literals,
where the heredoc delimiter often indicates the language
• Lua, which can contain snippets of Vimscript inside |vim.cmd()| calls.
• Vimscript, which can contain snippets of Lua inside |:lua-heredoc|
blocks.
All of these examples can be modeled in terms of a parent syntax tree and one
or more injected syntax trees, which reside inside of certain nodes in the
parent tree. The language injection query allows you to specify these
“injections” using the following captures:
• `@injection.content` - indicates that the captured node should have its
contents re-parsed using another language. If there are multiple
`@injection.content` captures in one pattern, all ranges will be
collected and parsed as one tree. This allows query authors to create
"scoped" injections with injection query quantifiers.
• `@injection.language` - indicates that the captured node’s text may
contain the name of a language that should be used to re-parse the
`@injection.content`.
• `@injection.filename` - indicates that the captured node’s text may
contain a filename; the corresponding filetype is then looked-up up via
|vim.filetype.match()| and treated as the name of a language that should
be used to re-parse the `@injection.content`.
The language injection behavior can also be configured by some properties
associated with patterns:
• `injection.language` - can be used to hard-code the name of a specific
language.
• `injection.combined` - indicates that all of the matching nodes in the
tree should have their content parsed as one nested document.
• `injection.include-children` - indicates that the `@injection.content`
node's entire text should be re-parsed, including the text of its child
nodes. By default, child nodes' text will be excluded from the injected
document.
• `injection.self` - indicates that the node's text should be parsed with
the same language as the node's LanguageTree.
• `injection.parent` - indicates that the captured node’s text should
be parsed with the same language as the node's parent LanguageTree.
Injection queries are currently run over the entire buffer, which can be slow
for large buffers. To disable injections for, e.g., `c`, just place an
empty `queries/c/injections.scm` file in your 'runtimepath'.
==============================================================================
VIM.TREESITTER *lua-treesitter*
The remainder of this document is a reference manual for the `vim.treesitter`
Lua module, which is the main interface for Nvim's treesitter integration.
Most of the following content is automatically generated from the function
documentation.
*vim.treesitter.language_version*
The latest parser ABI version that is supported by the bundled treesitter
library.
*vim.treesitter.minimum_language_version*
The earliest parser ABI version that is supported by the bundled treesitter
library.
==============================================================================
TREESITTER TREES *treesitter-tree* *TSTree*
A "treesitter tree" represents the parsed contents of a buffer, which can be
used to perform further analysis. It is a |userdata| reference to an object
held by the treesitter library.
An instance `TSTree` of a treesitter tree supports the following methods.
TSTree:copy() *TSTree:copy()*
Returns a copy of the `TSTree`.
Return: ~
(`TSTree`)
TSTree:root() *TSTree:root()*