How to have multiple colours for the same Treesitter value?
I am not sure, if this is the place to ask for this but; is it possible to have different colours depending not only on Treesitter, but on both Treesitter & Syntax?
Here is a sample code from Ruby on Rails project:
scope :ok_world, -> { where(ok_world: true) }
def hello
puts "Hello world!"
end
| Treesitter Enabled | Treesitter Disabled |
|---|---|
![]() |
![]() |
Playground data
call [266, 2] - [266, 41]
method: identifier [266, 2] - [266, 7]
arguments: argument_list [266, 8] - [266, 41]
simple_symbol [266, 8] - [266, 14]
lambda [266, 16] - [266, 41]
body: block [266, 19] - [266, 41]
call [266, 21] - [266, 39]
method: identifier [266, 21] - [266, 26]
arguments: argument_list [266, 26] - [266, 39]
pair [266, 27] - [266, 38]
key: hash_key_symbol [266, 27] - [266, 32]
value: true [266, 34] - [266, 38]
method [268, 2] - [270, 5]
name: identifier [268, 6] - [268, 11]
call [269, 4] - [269, 23]
method: identifier [269, 4] - [269, 8]
arguments: argument_list [269, 9] - [269, 23]
string [269, 9] - [269, 23]
string_content [269, 10] - [269, 22]
scope |
hello |
|---|---|
![]() |
![]() |
As shown above, Treesitter thinks both scope and hello is a TSFunction –which is technically true–, but they are not only a TSFunction:
-
scopeis aTSFunctionandrubyMacro. -
hellois aTSFunctionandrubyMethodName.
I hoped maybe lua/solarized/solarized-normal/highlights.lua file is similar to how CSS works and assigning Ruby specific colours after TSFunction like
syntax['TSFunction'] = syntax['Function']
syntax['rubyClassBlock'] = {fg=colors.red}
syntax['rubyMacro'] = {fg=colors.red}
can change how words are highlighted, but that did not work.
So, is it possible to override Treesitter highlighting with the Syntax one, whenever it is needed?
This is even an issue for me when highlighting some c code. It most likely can be configured with the treesitter setup but I have no idea as I don't use lsp and treesitter.



