diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-03-08 11:03:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-08 11:03:11 +0000 |
commit | ddd257f75301a50c177fc24a693d39a45b47a689 (patch) | |
tree | 052f09c521d467c31919ba6b67b085cf4bb234d3 /runtime/doc | |
parent | 06aed7c1776e9db769c77ce836c1995128a6afc6 (diff) | |
download | rneovim-ddd257f75301a50c177fc24a693d39a45b47a689.tar.gz rneovim-ddd257f75301a50c177fc24a693d39a45b47a689.tar.bz2 rneovim-ddd257f75301a50c177fc24a693d39a45b47a689.zip |
feat(treesitter): use upstream format for injection queries
Diffstat (limited to 'runtime/doc')
-rw-r--r-- | runtime/doc/news.txt | 4 | ||||
-rw-r--r-- | runtime/doc/treesitter.txt | 46 |
2 files changed, 50 insertions, 0 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index f5b9f39d93..04ae9360a0 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -196,6 +196,10 @@ The following new APIs or features were added. • Added an omnifunc implementation for lua, |vim.lua_omnifunc()| +• Treesitter injection queries now use the format described at + https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection . + Support for the previous format will be removed in a future release. + ============================================================================== CHANGED FEATURES *news-changes* diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 1f78e4d5d9..3b0936941f 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -441,7 +441,53 @@ individual query pattern manually by setting its `"priority"` metadata attribute: > (super_important_node) @ImportantHighlight (#set! "priority" 105) + +============================================================================== +TREESITTER LANGUAGE INJECTIONS *treesitter-language-injections* < + +Note the following information is adapted from: + https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection + +Some source files contain code written in multiple different languages. +Examples include: + + • HTML files, which can contain JavaScript inside of `<script>` tags and + CSS inside of `<style>` tags + • ERB files, which contain Ruby inside of `<%` `%>` tags, and HTML outside of + those 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. + • `@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`. + +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. + ============================================================================== VIM.TREESITTER *lua-treesitter* |