vim --clean
syntax include @INCLUDED syntax/c.vim syntax region FencedCodeBlockC start=/```c/ end=/```/ contains=@INCLUDED call setline(1, ['```c', '#if 0', 'int', '#else', 'int', '#if', '#endif', '```' ])
The #if
on line 6 should not be highlighted as cPreCondit
, because of this line in syntax file c.vim
:
syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\%(%:\|#\)\s*\%(else\|elif\)" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
It behaves correctly with a C file alone:
9.0.354
Operating system: Arch Linux
Terminal: kitty
Value of $TERM: xterm-kitty
Shell: fish
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
If patch 8.2.2761 is reverted, the #if
is highlighted correctly, but the int
is not:
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Do you know how to fix it? What if you revert (part of) patch 8.2.2761 ?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
I guess this is actually always broken. Looking at the code, it seems that both CONTAINED
and TOP
behave differently in an included syntax file from a top-level syntax file.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Yes, it appears unrelated to "syntax include".
If I change "contains=TOP,cPreCondit" from the cCppOutElse rule it seems to work better.
But then adding "#if/#endif" above the "#else" breaks the "out" highlight.
This may require another "contained" rule to match the nested #if/#endif
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
BTW, there is a more practical example using syntax/lua.vim
:
syntax include @INCLUDED syntax/lua.vim syntax region FencedCodeBlockLua start=/```lua/ end=/```/ contains=@INCLUDED call setline(1, ['```lua', 'print(1)', '```' ])
The last parenthesis is highlighted as luaParenError
:
It shouldn't be highlighted luaParenError
as it is specified after contains=TOP,
in syntax/lua.vim
:
syn region luaParen transparent start='(' end=')' contains=TOP,luaParenError
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
It seems this is because syn include
would simply replace all TOP
to the cluster name, thus contains=TOP,luaParenError
becomes contains=@INCLUDED,luaParenError
. And unfortunately, the two similar syntaxes have contradictory semantics: while the former prevents luaParenError
from being contained in region luaParen
, the latter allows luaParenError
to be contained. According to the document, both syn include
and contains` seems to work as intended.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
It's unbelievable that this issue has been open for more than a year.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
It's unbelievable that this issue has been open for more than a year.
We are only a limited number of people and can only do so much. However we are not obliged to provide you with fixes or even features. It may look strange, but we are doing this in our (limited) spare time for free for our users.
If you want to have this fixed, I invite you to help the community, analyze the issue, find the part in the code, fix it, create a test so that it doesn't regress and send a patch instead of complaining loudly and showing no respect to the work we are doing here.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.