luisiacc / gruvbox-baby

Gruvbox theme for neovim with full 🎄TreeSitter support.
MIT License
402 stars 28 forks source link

Function parameter rendered in the same color as a variable. #49

Closed jeffschwartz closed 2 years ago

jeffschwartz commented 2 years ago

Neovim supports semantic highlighting using Tree-sitter and LSP semantic tokens but function parameter declarations are not rendered consistently in the function body. I expected function parameters that are referenced in the function body to be rendered in the same color as they are rendered in their declarations but as the image below demonstrates, they are not. They are rendered as if they were declared in the function body (i.e. as variables)... at least in JavaScript and Typescript files.

Screenshot 2022-11-23 at 12 09 07 PM

Is there a config setting that I can use to address this?

My gruvbox-baby config:

let g:gruvbox_baby_function_style = "NONE"
let g:gruvbox_baby_keyword_style = "italic"
let g:gruvbox_baby_telescope_theme = 1
let g:gruvbox_baby_transparent_mode = 1
set background=dark
set termguicolors
colorscheme gruvbox-baby
luisiacc commented 2 years ago

Currently we have a way to extend the highlights with any you like:

vim.g.gruvbox_baby_highlights = {LspReferenceWhatever = {fg = "#123123", bg = "NONE", style="underline"}}

If you want to use the colors do this:

local colors = require("gruvbox-baby.colors").config()
jeffschwartz commented 2 years ago

Thank you @luisiacc. Unfortunately that doesn't really address the underlying problem which, btw, is not limited to only gruvbox-baby but is also exhibited by every color scheme that I have tried that claims to work with Treesitter. Apparently Treesitter is is not currently able to differentiate between function property declarations and function local variables when referenced from within the function body. Have you ever reached out to the maintainers of Treesitter regarding this? Obviously, or maybe not so obviously, there is a flaw in Treesitter's algorithm when it comes to C type languages.

BTW, in every other regard I ❤️ this color scheme and I intend to keep using it :).

luisiacc commented 2 years ago

I think treesitter doesn't go as far as identifying the semantics of every token, I think what you are referring to is semantic highlighting, which highlights tokens according to their semantic meaning, like references of the same variable, some lsp providers do provide some of this highlighting but others don't, currently there is no highlight for semantic tokens from the lsp on this scheme, but there will be, although I don't know if they will do exactly what you expect.

jeffschwartz commented 2 years ago

Yes, @luisiacc, that is exactly what I am referring to. Sorry if I didn't make that more explicit in my op. I am looking forward to Neovim's future support for semantic highlighting. I have been salivating over it ever since I heard Douglas Crockford make mention of it numerous years ago. Thank you again for gruvbox-baby. It has answered many of the issues I had with other implementations of gruvbox.