Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to have multiple colours for the same Treesitter value? #41

Open
ogirginc opened this issue Jan 21, 2022 · 1 comment
Open

How to have multiple colours for the same Treesitter value? #41

ogirginc opened this issue Jan 21, 2022 · 1 comment

Comments

@ogirginc
Copy link

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
Screenshot 2022-01-21 at 23 28 03 Screenshot 2022-01-21 at 23 28 17
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
Screenshot 2022-01-21 at 23 29 50 Screenshot 2022-01-21 at 23 30 23

As shown above, Treesitter thinks both scope and hello is a TSFunction –which is technically true–, but they are not only a TSFunction:

  • scope is a TSFunction and rubyMacro.
  • hello is a TSFunction and rubyMethodName.

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?

@ishan9299
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants