sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.83k stars 164 forks source link

Question: is c++ class member variable supposed to be highlighted regardless what naming style we use? #192

Closed solotim closed 4 months ago

solotim commented 6 months ago

redhat 7.x + xterm + tmux 3.2 + nvim 0.82 + clangd + treesitter + gruvbox material

I found the class member variable won't be highlighted if use certain naming style.

Example 1:

// foo1.h
class Foo {
  void op();
  int m_count;
}
// foo1.cc
Foo::op() { printf("%d", m_count); }  //<-- m_count is highlighted 

Example 2:

// foo2.h
class Foo {
  void op();
  int _count;
}
// foo2.cc
Foo::op() { 
    printf("%d", _count);            //<-- _count is NOT highlighted 
    printf("%d", this->_count);   //<-- _count is highlighted 
}  

Is this expected? Or is it a bug?

antoineco commented 6 months ago

That's related to Tree-sitter (or LSP semantic highlights, but I don't think these are available in Neovim 0.8).

Can you move your cursor to the symbol(s) and compare the output of :TSHighlightCapturesUnderCursor? (:Inspect starting with Neovim 0.9)

sainnhe commented 6 months ago

It's the problem of highlighting engine. There are a lot of highlighting engines in nvim, to name a few:

  1. Built-in highlighting engine using regex.
  2. Tree-sitter highlighting engine.
  3. Semantic highlighting engine provided by language server.

It depends on the highlighting engine whether a token should be highlighted or not, not a color scheme.

solotim commented 6 months ago

@antoineco , my nvim don't have :TSHighlightCapturesUnderCursor command

Thanks for the reply. I agree it doesn't look like a bug in the theme. I'll dig more.

antoineco commented 6 months ago

Ah my bad, the command is provided by https://github.com/nvim-treesitter/playground

antoineco commented 6 months ago

@solotim did you get a chance to try the command after installing the aforementioned plug-in?

antoineco commented 4 months ago

This issue seems to have become inactive, but here is the answer to my above question, for posterity:

image

In the first print:

Treesitter
  - @variable.cpp links to Fg cpp

In the second print:

Treesitter
  - @_parent.cpp links to @_parent cpp
  - @property.cpp links to Blue cpp

To me the result seems expected in the context of Tree-sitter. LSP semantic highlights would probably be able to determine the context more accurately.