jeaye / color_coded

A vim plugin for libclang-based highlighting of C, C++, ObjC
MIT License
870 stars 53 forks source link

default syntax not loaded if lazy loaded by vim-plug #163

Open unnamed42 opened 6 years ago

unnamed42 commented 6 years ago

As is described in title, vim-plug won't load after/syntax/color_coded.vim if is set to lazy loading, like:

Plug 'jeaye/color_coded', {'for': ['c', 'cpp', 'objc', 'objcpp']}

I've found the code for loading syntax, in plugin/color_coded.vim:

au VimEnter,ColorScheme * source $VIMHOME/after/syntax/color_coded.vim

Maybe both VimEnter and ColorScheme are not captured.

jeaye commented 6 years ago

Hey, @unnamed42. Thanks for creating this issue. I've also experienced problems with lazy loading color_coded and have typically just disabled the lazy loading, so I never looked much into it.

Both VimEnter and ColorScheme are captured there, since we want to reload color_coded whenever the colorscheme changes and we also want to load it on startup (or do we?). Perhaps a better solution is to use another event which only triggers upon the plugin being loaded. I'm not too sure of how to hygienically lazy load plugins at this moment; do you know of some better suited events we should hook instead?

unnamed42 commented 6 years ago

According to the wiki page, when some plugin is lazy loaded, vim-plug will fire a User event whose name is the same as the plugin. So I add a line after syntax loader:

au User color_coded source $VIMHOME/after/syntax/color_coded.vim

And everything looks OK now.

jeaye commented 6 years ago

Wow, great find. We may want to keep all three then. VimEnter, ColorScheme, and User color_coded.

UnrealQuester commented 6 years ago

Can confirm that this fixes the issue. Do you want to make a PR for this @unnamed42?