mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 09:50:04 -04:00
refacto: expose a function to set custom capture for the higlighter
BREAKING: deprecate custom_captures from highlight config. This allows plugin authors to extend the map. It also avoids settings user configuration specific values during the highlighter initialization (SOC). Not sure how much value this brings, and might potentially break a lot of people configurations. This is questionable.
This commit is contained in:
parent
af71c25edc
commit
560e8fb450
4 changed files with 31 additions and 19 deletions
15
README.md
15
README.md
|
|
@ -273,10 +273,6 @@ Consistent syntax highlighting.
|
|||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = {
|
||||
enable = true,
|
||||
custom_captures = {
|
||||
-- Highlight the @foo.bar capture group with the "Identifier" highlight group.
|
||||
["foo.bar"] = "Identifier",
|
||||
},
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
|
|
@ -286,6 +282,17 @@ require'nvim-treesitter.configs'.setup {
|
|||
}
|
||||
```
|
||||
|
||||
You can add custom highlight captures with:
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
#### Incremental selection
|
||||
|
||||
Incremental selection based on the named nodes from the grammar.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue