arynaq
arynaq

Reputation: 6870

Vim: syntax files, load order is wrong

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

Upvotes: 2

Views: 546

Answers (1)

Luc Hermitte
Luc Hermitte

Reputation: 32966

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.

Upvotes: 2

Related Questions