aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2022-10-16 15:58:50 +0200
committerChristian Clason <christian.clason@uni-due.de>2022-10-17 09:20:42 +0200
commitde2fa5327a566c16cdf85984f3c4fff7aafecc97 (patch)
treecfa6dc4ef654f2505925a86b9df13398fecf5166
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-de2fa5327a566c16cdf85984f3c4fff7aafecc97.tar
nvim-treesitter-de2fa5327a566c16cdf85984f3c4fff7aafecc97.tar.gz
nvim-treesitter-de2fa5327a566c16cdf85984f3c4fff7aafecc97.tar.bz2
nvim-treesitter-de2fa5327a566c16cdf85984f3c4fff7aafecc97.tar.lz
nvim-treesitter-de2fa5327a566c16cdf85984f3c4fff7aafecc97.tar.xz
nvim-treesitter-de2fa5327a566c16cdf85984f3c4fff7aafecc97.tar.zst
nvim-treesitter-de2fa5327a566c16cdf85984f3c4fff7aafecc97.zip
fix(readme): update highlight instructions
-rw-r--r--README.md21
1 files changed, 13 insertions, 8 deletions
diff --git a/README.md b/README.md
index 3b0bda0ea..28ffd55a3 100644
--- a/README.md
+++ b/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.