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

Custom C/C++ syntax broken after commit cbde2571d4f79770ac552fe75440de72893bc73a #608

Closed
kostiskalkounos opened this issue Oct 25, 2020 · 16 comments

Comments

@kostiskalkounos
Copy link

kostiskalkounos commented Oct 25, 2020

I use a custom function to highlight C/C++ objects and it was working perfectly before the aforementioned commit: 'Respect symlinks for resolving vim-polyglot as fallback, closes #601'

The problem seems to be that the custom .vim/after/syntax/c.vim is the only file read , where before, the custom changes were applied on top of bfrg/vim-cpp-modern/after/syntax/c.vim

Before:

Screen Shot 2020-10-25 at 12 22 54

After:
Screen Shot 2020-10-25 at 12 22 30

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Could you send your .vimrc ?

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Here are two screenshots, one with Plug 'sheerun/vim-polyglot' commented, and second one uncommented. There's no difference. Maybe you need to update or something? I can try to fix it but I cannot reproduce

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Okay, I see the difference, but only when using neovim, I'll try to fix it

@kostiskalkounos
Copy link
Author

kostiskalkounos commented Oct 25, 2020

I never disabled your plugin, I just reverted back to an older commit to show the expected behavior.
I have this issue both in ViM and Neovim, so it's not Neovim specific.

I'll try to explain the issue better:

My first screenshot shows everything working as expected. I have my custom types highlighted in yellow, the function name is blue and the const keyword is purple.

In order to have const highlighted in purple I need to enable the behavior through the bfrg/vim-cpp-modern/ plugin, which you support, with this line in my .vimrc let g:cpp_simple_highlight = 1.

After the introduction of the aforementioned commit, things broke. To be precise the function name stopped being blue and the const keyword is yellow.

My types are correctly highlighted though, which makes me think that the syntax file of the plugin is ignored in favor of my custom syntax file.

UPDATE:

I removed your plugin and I installed bfrg/vim-cpp-modern/ and everything works as expected, so I'm certain this commit is the culprit.

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Your custom file should be named after/syntax/cpp.vim, not after/syntax/c.vim, because vim-cpp-modern is loaded as after/cpp.vim. It's hard to guarantee that after/cpp.vim of other plugins will always load before yours after/c.vim. This only works because vim-plug cares about loading order which would not be the case for example for vim 8 packages

@kostiskalkounos
Copy link
Author

kostiskalkounos commented Oct 25, 2020

If I do this it works as expected for C++ syntax highlighting but it breaks for C.
Before this commit it was working correctly for both.

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Ok I guess I'll need to ensure loading order is preserved even though Bram says otherwise: vim/vim#7056 (comment)

@kostiskalkounos
Copy link
Author

If I understood what I read correctly, Bram believes that we should be able to add new things on top of the preexisting ones without overriding them, hence why my syntax file was working correctly before. Am I missing something?

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Bram says that plugins should not dependon order of loading of each other. In your case you're depending on after files of vim-cpp-modern to load before your after files. It seems recent changes of vim-polyglot changed this order, I'll try to revert that

@kostiskalkounos
Copy link
Author

Ah I see, it's clear now, thanks for the explanation!

@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Should be fine now, the loading order is as follows:

  1. All paths until $VIMRUNTIME
  2. Vim-polyglot
  3. $VIMRUNTIME
  4. vim-polyglot after
  5. all other after files

@kostiskalkounos
Copy link
Author

kostiskalkounos commented Oct 25, 2020

It's still broken. The bfrg/vim-cpp-modern plugin isn't called at all, unless I have to call it in a different way.

If it's tricky to fix, you can revert the changes and I will maintain a hacky version to have the expected output.

Actual:
Screen Shot 2020-10-25 at 20 47 39

Expected:
Screen Shot 2020-10-25 at 20 50 27

sheerun added a commit that referenced this issue Oct 25, 2020
@sheerun
Copy link
Owner

sheerun commented Oct 25, 2020

Sorry, now should work. I made silly mistake

@kostiskalkounos
Copy link
Author

It's perfect, thanks a ton!

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

No branches or pull requests

2 participants