Just as a preface – I’m very new to Neovim (installed and configured it last week), so forgive me for my knowledge gaps.
I’m trying to update the priority defined by treesitter for the @lsp.typemod.variable.declaration.typescriptreact
highlight group, since it has the same priority as @lsp.typemod.variable.readonly.typescriptreact
and I would like the former group to take priority.
I tried using highlight link
, but since they have the same priority, sometimes the former group takes precedence and sometimes the latter group takes precedence.
From the docs and from reading online, it seems like creating a new capture group associated with @lsp.typemod.variable.declaration.typescriptreact
and setting a higher priority would be the solution here.
Unfortunately, everything I’ve tried so far doesn’t seem to work. I’ve created a highlights.scm
folder under nvim/after/queries/tsx/highlights.scm
and added this code:
;; extends
((variable_declaration) @lsp.typemod.variable.declaration.typescriptreact (#set! "priority" 128))
And in my setup function for treesitter I’ve added this code (using lazy.nvim):
{
'nvim-treesitter/nvim-treesitter',
opts = {
...
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
custom_captures = {
["variable_declaration"] = "Type"
}
},
},
...
}
Here, I’m attempting to map the variable_declaration
capture group that I’ve just defined to the Type
highlight colour.
I’m sure I’m missing something obvious here, but I’ve been banging my head against the wall trying tons of different solutions so I figured I’d bring my question here.
Thanks for the help!