I’ve just decided to try out NeoVim as my editor, and I’m trying to get syntax highlighting that is
consistent with my current environment (Visual Studio). I used the guide by ThePrimeagen,
as my starting point, who uses Tree-Sitter + LSP-Zero + the Rosè-Pine color scheme (I did not edit any parser files, only capture/palette associations and the palette itself).
However, when opening C++ files, I’m noticing several inconsistencies, that appear to be Language Server related(I’m using clangd, via lsp-zero, using the “recommended” preset).
Note: Since I cannot embed images or use more than 2 hyperlinks, please see the bottom of the post for mangled image links (replace _ with : and .). Also, since this forum uses the at-sign to tag users, I’ve replaced it in the capture group names with [at].
Struct fields should have a specific color (off-white), but sometimes this is not applied, as seen in the picture. The color is set with [at]lsp.type.property->[at]property,
but [at]lsp.type.property is not tagged for “Source”. Similarily, stringToView is not tagged with [at]lsp.type.parameter in the constructor body.
I should mention that I’m using the “Inspect” command to view the capture groups, which seems the most accurate (tree-sitter-playground does not appear to show language server highlight groups,
and hitest.vim appears to not be representing final highlights at all).
At first, I had assumed that capture groups like [at]constructor, [at]property, and [at]field would work with tree-sitter on its own, but in dealing with this issue I’m getting the sense that a language server is
necessary to get the intended behaviour, is that correct?
Asides:
- For at least several days, the c parser was flagged as potential malware by Windows, so I had to exclude it from the ones in the ensure_installed call for a bit. What’s that about?
- Right now I’m directly editing the theme files that came with the color scheme. I assume I need to take some measure to not have those changes overwritten if the color scheme is ever
updated?
Thanks in advance!
Malfunctioning Syntax Highlighting: https_//pasteboard_co/PT6jYDWtZcF8_png
Correct Syntax Highlighting: https_//pasteboard_co/X1C3dJlPGSuA_png
Source/stringToView Capture Groups: https_//pasteboard_co/OgR3Q1uL5C22_png
StartIndex Capture Groups: https_//pasteboard_co/ZrsfFhL75A3q_png
Edit: As it turns out, the syntax inconsistencies were (mostly or entirely) due to supposed errors in my code, that affected the language server’s interpretation of what was going on. I’ve since had a better experience with the syntax highlighting.