Closed taekwombo closed 10 months ago
Your patch looks fine, thanks! PR welcome, hopefully with a test case :)
What does the tree look like after your change?
I was mistaken, there is no issue with the grammar structure here. I have spent some time to check this issue again, this time I wiped out both old runtime files of nvim and any plugins then installed nvim from source again.
Regardless of the changes there I made to the grammar there was no difference in highlighting. :sweat_smile:
If I understand what happened correctly, it goes like this:
codeblock
are highlighted with @text.literal
- this is correctcodeblock
and highlights some nodes accordingly to its highlights queries - this is also correctcodeblock
color, even though in regular file they would be displayed with Normal
highlightIf the range handled by injected parser would be highlighted with Normal
the final highlights would be the same as in regular file. I will search for issues/discussions about it and try to come up with some solution.
I am closing this issue because this has nothing to do with grammar.
Yes, this is the correct interpretation. You can check your colorscheme to make sure it actually assigns colors to "white" (or black, depending on your background) instead of setting them to NONE
to default to the built-in Normal
group. These should then still paint over the codeblock.
Colorscheme is okay - checked that with built-in retrobox. It's more likely the context that matters.
Let's say I have defined only the following highlights queries for C:
((identifier) @variable)
Then I would end up with those highlights in C file: and those highlights in help file:
Injected highlights work fine, but the Normal
highlight color for injected highlights becomes whatever it paints on. :)
Yes, that's my point -- it shouldn't be Normal
.
Hi, some time ago I have noticed a problem where some tokens from injections in vimdoc code block are highlighted with color of
@text.literal.vimdoc
.nvim -V
:nvim -u NORC
::Inspect
overage
variable (its color is the problem).:InspectTree
for the code block:Regular C file
So, my first guess was that
(line)
nodes somehow break the highlights. I updated the parser a little bit so that the(line)
children of(code)
are inlined and this is the result:There was the same issue in https://github.com/nvim-treesitter/nvim-treesitter/issues/4887 - they fixed it by lowering the priority of the code block highlight.
Here is my approach (it will require snapshot updates). Let me know if I should create a PR for this issue and which way of fixing it you prefer.