-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C/C++ incorrect syntax region #55
Comments
Yes, this is something that I had noticed as well, but looks like I never logged the issue. Thanks for submitting it. When I tried to sort this out, it seemed to be a problem with one of those syntax files, but I could not make any more progress at the time. Your example is a bit odd in that there should be a blank line between the directive and the code block. That may be affecting things as well here. |
I've figured out what exactly happens there. If you take a look into the C++ syntax file ( Taking the example you posted, place the cursor at the opening :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') and you will get: ['rstDirectivecpp', 'cBlock', 'cBlock'] This means that the Now lets check the definition of :syn list cBlock and you will get: --- Syntax items ---
cBlock xxx start=/{/ end=/}/ contained transparent fold
start=/{/ end=/}/ contained transparent fold You can see the duplicate patterns defined for When reaching the closing I've thought about why 'c' is not added to I attempted to fix this by introducing extra code to define the |
Thank you @madjxatw for solving this mystery, your explanation makes a lot of sense. This looks like an interesting solution to a very difficult problem. It would be nice if there were a way to catch the more general issue of recursive highlighting, since quite a few syntax languages do this. For example, I think php inherits html! In the meantime, I'll try to find some time to work through your solution. |
Hi,
I attempted to add
'c': ['c']
to theg:rst_syntax_code_list
to enable C syntax highlighting but run into the issue with c and cpp code blocks as described below.Given the following rst text:
Both 'using' are highlighted as C++ statement. It seems that 'c' and 'cpp' cannot be specified simultaneously in
g:rst_syntax_code_list
.The text was updated successfully, but these errors were encountered: