2

I am stuck trying to figure out how I can get vim to load a specific syntax file for filetype cpp.

Running :setlocal syntax? yields syntax=cpp which makes me suspect that cpp.vim from lines 47-48 is loaded. The actual syntax file I want to use is the at the bottom of the scriptnames output. I know that it isn't being loaded because the colors are wrong.

 1: /etc/vimrc 2: /usr/share/vim/vimfiles/archlinux.vim 3: ~/.vimrc 4: /usr/share/vim/vim80/ftoff.vim 5: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim 6: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim 7: /usr/share/vim/vim80/filetype.vim 8: /usr/share/vim/vim80/ftplugin.vim 9: /usr/share/vim/vim80/indent.vim 10: /usr/share/vim/vim80/syntax/syntax.vim 11: /usr/share/vim/vim80/syntax/synload.vim 12: /usr/share/vim/vim80/syntax/syncolor.vim 13: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim 14: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim 15: ~/.vim/bundle/nerdtree/lib/nerdtree/path.vim 16: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim 17: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim 18: ~/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim 19: ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim 20: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim 21: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim 22: ~/.vim/bundle/nerdtree/lib/nerdtree/opener.vim 23: ~/.vim/bundle/nerdtree/lib/nerdtree/creator.vim 24: ~/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim 25: ~/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim 26: ~/.vim/bundle/nerdtree/lib/nerdtree/ui.vim 27: ~/.vim/bundle/nerdtree/lib/nerdtree/event.vim 28: ~/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim 29: ~/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim 30: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim 31: ~/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim 32: ~/.vim/bundle/powerline/powerline/bindings/vim/plugin/powerline.vim 33: /usr/share/vim/vim80/plugin/getscriptPlugin.vim 34: /usr/share/vim/vim80/plugin/gzip.vim 35: /usr/share/vim/vim80/plugin/logiPat.vim 36: /usr/share/vim/vim80/plugin/manpager.vim 37: /usr/share/vim/vim80/plugin/matchparen.vim 38: /usr/share/vim/vim80/plugin/netrwPlugin.vim 39: /usr/share/vim/vim80/plugin/rrhelper.vim 40: /usr/share/vim/vim80/plugin/spellfile.vim 41: /usr/share/vim/vim80/plugin/tarPlugin.vim 42: /usr/share/vim/vim80/plugin/tohtml.vim 43: /usr/share/vim/vim80/plugin/vimballPlugin.vim 44: /usr/share/vim/vim80/plugin/zipPlugin.vim 45: /usr/share/vim/vim80/ftplugin/cpp.vim 46: /usr/share/vim/vim80/ftplugin/c.vim 47: /usr/share/vim/vim80/indent/cpp.vim 48: /usr/share/vim/vim80/syntax/cpp.vim 49: /usr/share/vim/vim80/syntax/c.vim 50: ~/.vim/bundle/vim-cpp-enhanced-highlight/after/syntax/c.vim 51: ~/.vim/bundle/vim-cpp-enhanced-highlight/after/syntax/cpp.vim 

How do I change the order in which they are loaded? Or even force it to load only a specific cpp.vim? My .vimrc is available here https://gist.github.com/arynaq/1aa9011f636076e2d2766dff82e8b4af

1 Answer 1

2

The fact you see it at the end of :scriptnames results means it is loaded.

To change the load order, you'd need to move the script from syntax/after to syntax/. But I'm quite certain this is not how the author expects it to work -- as the standard syntax/c.vim would clear the highlighting defined the new syntax plugin. BTW loading the standard syntax scripts for C and C++ is expected in your your case. Their presence, lines 48-49, is normal.

It seems that if you try to complete :hi cpp you should observe many cppSTL entries from this syntax plugin.

You'd need to be more specific about what you think is wrong. But honestly, this is quite certainly a question for the plugin author. Be sure you have correctly read the documentation and set the options to suit your expectations.

Sign up to request clarification or add additional context in comments.

3 Comments

There are no specifics to running it, it is just a set of syntax files. I think you defined the problem better than in my OP, I think the standard syntax scripts overload my custom scripts. I know it isn't working because the scripts differ in color highlighting of eg functions.,
On the plugin repo (github.com/octol/vim-cpp-enhanced-highlight), I see the options documented. The source code, and the fact the syntax script is in after/ subdirectory tell me you're in the nominal scenario. $VIMRUNTIME/syntax/c.vim and cpp.vim shall be loaded first, then the new plugin adds complementary definitions. However, many are activated or deactivated depending on options.
BTW the standard syntax file for C and C++ cannot override the new ones as they are defined before. There sometimes some odd precedences rules when defining highlighting schemes. But then if there is something wrong, you'll have to see with the plugin maintainer. Anyway, I'm convinced you've installed/activated the plugin the way it's meant to be.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.