Closed mtvec closed 2 years ago
The designs of classic vim syntax highlighting and tree-sitter / semantic highlighting are totally different, see explanation here https://github.com/sainnhe/gruvbox-material/issues/109
I understand highlighting can be done much more optimal when tree-sitter/semantic highlighting is used. However, I do not understand why there need to be inconsistencies with the classic vim syntax highlighting. Why not use the same colors for String
, TSString
, and CocSymbolString
?
I'm sure I'm missing something here though. Is it maybe a feature to be able to see which syntax engine is being used based on the colors?
However, I do not understand why there need to be inconsistencies with the classic vim syntax highlighting.
In short, it's impossible to keep them consistent.
Say if we want to use green in function names, we can link TSFunction
to Green
, then all function highlights provided by TS will become green, this is expected.
However, this is not the case in the classic vim syntax highlighting. In many languages, you can't get the function name highlighted (e.g. C and JS).
To get a better overall feeling, the highlighting logic are completely redesigned.
I understand, but wouldn't it still make sense to keep consistency where possible?
Let me give an example of what currently annoys me. Say I like to have italic keywords. Great, I just set g:gruvbox_material_enable_italic
and everything seems fine. However, it is only fine for languages for which I don't have tree-sitter of coc.nvim support because TSKeyword
is linked to Red
instead of RedItalic
.
I like to have consistency between the different languages I'm working with. I fully understand (and like!) that better highlighting can be provided when semantic tokens are available. I don't mind seeing the colors of functions switch after the language server has been loaded on a C file because I understand that more information has now become available. However, I do not like seeing keywords becoming non-italic at the same time because those are already correctly parsed without the language server. No extra information is provided by changing the style, so it just becomes a cognitive burden for me.
OK I'm going to explain my thoughts in detail:
First of all, when I'm designing a color scheme, the very first thing is to guarantee a good overall feel, and everything else is secondary. That's said, when something else happens that conflicts with this principle, this principle take precedence.
And when designing a color scheme, I personally created 2 new concepts: the primary colors and the secondary colors:
The primary colors are those that can be widely used and give a nice overall feel, while the secondary colors are mainly used to set off the primary colors, which intend to make the color scheme more colorful. The secondary colors should not be widely used.
For example in this color scheme, the primary colors are red, orange, yellow and green, these are warm colors and can be widely used. While aqua, blue and purple are secondary colors and should not be widely used, they tend to be cooler. If we widely use blue, aqua and purple in this color scheme, the overall feel will be very bad.
Now back to your questions.
If we do so, as I mentioned above, in some languages you'll only see aqua and there will be no green because function name can't be highlighted. In other words, aqua which is one of the secondary colors, will be widely used. That will cause a bad overall feel.
And as I said, when I'm designing color schemes, the very first thing is to guarantee a good overall feel, everything else is secondary. So even if this highlighting logic is inconsistent with that is in TS highlighting, I still chose not to use aqua in string.
There are 2 widely accepted highlighting logic for italics:
a. Italicize keywords b. Italicize type, classes, builtin variables (like self, super), etc.
In my personal opinion, b. is actually better, because with a. almost all italics are centered on the left side of your editor, while with b. italicized keywords are more evenly distributed in your whole editor.
That's said, b. have a better overall feel.
However we can't implement b. in classic vim syntax highlighting because the classic highlighting engine is so bad, but it's possible to implement a., so using a. in classic syntax highlighting is actually a compromise. When comes to TS where b. is possible, I chose to implement b.
Yes I must admit that this approach is very aggressive, but that's how I design my color schemes.
If you have reservations about my opinion, that OK because this is an open source project. Neovim community disagree with Vim's on some points so they forked Vim and start over. Also, you are always welcome to fork this repo, or create your new one, or use others' ports (looks like some people have ported this color scheme to neovim in lua).
Alright, thanks a lot for your detailed explanation! It's very much appreciated. I understand your point better now and I agree with it.
Operating system/version
Ubuntu 21.10
Terminal emulator/version
alacritty 0.9.0
$TERM environment variable
alacritty
Tmux version
No response
Feature matrix
Minimal vimrc that can reproduce this bug.
Steps to reproduce this bug using minimal vimrc
:CocInstall coc-rust-analyzer
(or any other language server that supports semantic highlighting of strings).Expected behavior
The highlighting of strings is independent of whether Vim's builtin syntax rules detected them or the language server did.
Actual behavior
When no language server is used, or one is used that doesn't support semantic highlighting of strings (e.g., clangd), strings are assigned to the
String
highlighting group which is highlighted usings:palette.green
:With a language server that supports this, strings are assigned to the
CocSymbolString
group which is linked to theAqua
group, causing different highlighting:I think it would make sense to make this consistent and maybe just link
CocSymbolString
(and alsoTSString
) directly toString
.However, I actually prefer the
Aqua
highlighting of strings because otherwise, strings are assigned the same color as functions which highlights too many things in the same color IMHO. I could easily change this locally of course.