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

Distinguish TSSymbol from TSVariable #112

Closed
mikehaertl opened this issue Jan 12, 2025 · 5 comments
Closed

Distinguish TSSymbol from TSVariable #112

mikehaertl opened this issue Jan 12, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@mikehaertl
Copy link

mikehaertl commented Jan 12, 2025

In the current implementation TSSymbol (@symbol) and TSVariable (@variable) are both linked to Fg.

But I think that symbols have a quite different meaning in most languages, more like constants. So I suggest to make them also visually distinguishable from variables.

For example in Elixir a symbol (i.e. atom) is a global constant that looks like :foo or foo:.

The default schema makes it hard to see the difference.
image

Here I have :hi link TSSymbol Orange:
image

@antoineco
Copy link
Collaborator

I think that's reasonable. In the colorscheme we highlight the general purpose group @symbol, but this is a remnant from older Neovim versions which was since renamed to @string.special.symbol. :h treesitter-highlight-groups doesn't list the former anymore.

For reference, I ran a GitHub search for /@string.special.symbol/ path:/^queries\/highlights.scm/, which found this group used in the following grammars:

  • solidity
  • ruby
  • elixir
  • julia
  • erlang
  • haskell

@antoineco antoineco added the enhancement New feature or request label Jan 12, 2025
@antoineco antoineco changed the title Feature Request: Distinguish TSSymbol from TSVariable Distinguish TSSymbol from TSVariable Jan 12, 2025
@antoineco
Copy link
Collaborator

antoineco commented Jan 12, 2025

Tried the change on an Elixir file, but the result was aggressive to say the least:

before
before

after (TSField)
after TSField

after (TSAttribute)
after TSAttribute

Granted, the file may not be representative of the typical Elixir code. In particular, values are mostly literals whereas in your code they are mostly variables.

@mikehaertl
Copy link
Author

Your example shows an app configuration so it's clear that it's full of atoms (symbols) as all of them are well-known config keys. IMO they should pop out to separate them from variables.

So I still think the change would make sense. But of course it all also boils down to personal taste.

Even here at github they use different colors (blue vs. black). They are almost not distinguishable but github's color scheme in general has less contrast.

defmodule KV.BucketTest do
  use ExUnit.Case, async: true

  setup do
    {:ok, bucket} = KV.Bucket.start_link([])
    %{bucket: bucket}
  end

  test "stores values by key", %{bucket: bucket} do
    assert KV.Bucket.get(bucket, "milk") == nil

    KV.Bucket.put(bucket, "milk", 3)
    assert KV.Bucket.get(bucket, "milk") == 3
  end
end

@antoineco
Copy link
Collaborator

antoineco commented Jan 13, 2025

@sainnhe I'm thinking about linking @string.special.symbol.ruby and @string.special.symbol.elixir to TSField (Orange) in Ruby and Elixir files. Any objection from your side?

For information, these are linked to Constant in Vim's built-in syntax, which is Orange (Vim) / Fg (Tree-Sitter) in Sonokai.


from this
image

to this
image

@sainnhe
Copy link
Owner

sainnhe commented Jan 23, 2025

@antoineco Sorry for late reply. It looks good to me. I don't write Ruby and Elixir so I'd respect your opinion on this.

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

No branches or pull requests

3 participants