Skip to content
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

Move syntax files for C and C++ to an after/ directory. #2

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

filbranden
Copy link
Contributor

@filbranden filbranden commented Apr 4, 2020

These syntax files need to be loaded after the syntax files from the Vim runtimes. Otherwise, they break rules such as cParen, which no longer sees the right parenthesis and causes a block of curly braces that follows it to produce errors.

Tested with a very simple C source code buffer:

int main(int argc, char **argv)
{
	return 0;
}

Before this commit, the curly braces would be highlighted in error background, being marked as Error. After this commit, they look and behave correctly.

This does disable syntax rules such as cParen from the Vim runtimes, which is unfortunate. Those rules don't normal produce highlighting, except for cases where there are unbalanced parentheses or brackets, in which case it can highlight some of them as errors. However, without these rules, the colors in overwrite_c_highlight will not work. It's a tradeoff, I guess.

See also this question on Stack Overflow and my answer discussing the rationale for the change.

These syntax files need to be loaded *after* the syntax files from the Vim
runtimes. Otherwise, they break rules such as cParen, which no longer sees the
right parenthesis and causes a block of curly braces that follows it to produce
errors.

Tested with a very simple C source code buffer:

    int main(int argc, char **argv)
    {
	return 0;
    }

Before this commit, the curly braces would be highlighted in error background,
being marked as Error. After this commit, they look and behave correctly.

This does disable syntax rules such as cParen from the Vim runtimes, which is
unfortunate. Those rules don't normal produce highlighting, except for cases
where there are unbalanced parentheses or brackets, in which case it can
highlight some of them as errors. However, without these rules, the colors in
overwrite_c_highlight will not work. It's a tradeoff, I guess.
@kyoz kyoz merged commit cfa6fb1 into kyoz:master Apr 4, 2020
@kyoz
Copy link
Owner

kyoz commented Apr 4, 2020

Thanks @filbranden. This's great

@filbranden filbranden deleted the fix-c-syntax branch April 4, 2020 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants