mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
fix(readme): update highlight instructions
This commit is contained in:
parent
c27597b436
commit
de2fa5327a
1 changed files with 13 additions and 8 deletions
21
README.md
21
README.md
|
|
@ -331,17 +331,22 @@ require'nvim-treesitter.configs'.setup {
|
|||
}
|
||||
```
|
||||
|
||||
You can add custom highlight captures with:
|
||||
To customize the syntax highlighting of a capture, simply define or link a highlight group of the same name:
|
||||
|
||||
```vim
|
||||
lua <<EOF
|
||||
require"nvim-treesitter.highlight".set_custom_captures {
|
||||
-- Highlight the @foo.bar capture group with the "Identifier" highlight group.
|
||||
["foo.bar"] = "Identifier",
|
||||
}
|
||||
EOF
|
||||
```lua
|
||||
-- Highlight the @foo.bar capture group with the "Identifier" highlight group
|
||||
vim.api.nvim_set_hl(0, "@foo.bar", { link = "Identifier" })
|
||||
```
|
||||
|
||||
For a language-specific highlight, append the name of the language:
|
||||
|
||||
```lua
|
||||
-- Highlight @foo.bar as "Identifier" only in Lua files
|
||||
vim.api.nvim_set_hl(0, "@foo.bar.lua", { link = "Identifier" })
|
||||
```
|
||||
|
||||
See `:h treesitter-highlight-groups` for details.
|
||||
|
||||
#### Incremental selection
|
||||
|
||||
Incremental selection based on the named nodes from the grammar.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue