2017-03-02 27 views
0

我被困在试图弄清楚如何让vim为filetype cpp加载特定的语法文件。Vim:语法文件,加载顺序错误

正在运行:setlocal syntax?收益率​​这让我怀疑加载了第47-48行的cpp.vim。我想要使​​用的实际语法文件位于scriptnames输出的底部。我知道它没有被加载,因为颜色是错误的。

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 

如何更改它们的加载顺序?或者甚至强迫它只加载一个特定的cpp.vim?我.vimrc可以在这里找到https://gist.github.com/arynaq/1aa9011f636076e2d2766dff82e8b4af

回答

1

你看到它在:scriptnames结果结束,这意味着它加载。

要更改加载顺序,您需要将脚本从syntax/after移动到syntax/。但我相当肯定这不是作者期望它的工作方式,因为标准syntax/c.vim将清除突出显示定义的新语法插件。顺便说一句,加载C和C++的标准语法脚本在你的情况下预计。他们的存在,48-49行,是正常的。

看来,如果您尝试完成:hi cpp,则应该观察此语法插件中的许多cppSTL条目。

你需要对你认为是错误的更具体。但说实话,这对插件作者来说肯定是一个问题。确保您已正确阅读文档并设置适合您期望的选项。

+0

没有具体的运行它,它只是一组语法文件。我认为你比我的OP更好地定义了问题,我认为标准语法脚本会超出我的自定义脚本。我知道这是行不通的,因为脚本在例如函数的颜色突出显示方面有所不同。, – arynaq

+0

在插件回购(https://github.com/octol/vim-cpp-enhanced-highlight)上,我看到了选项。源代码以及语法脚本在'/子目录之后的事实告诉我你是名义场景。 '$ VIMRUNTIME/syntax/c.vim'和'cpp.vim'应该先加载,然后新的插件添加补充定义。但是,根据选项,许多设备被激活或停用。 –

+0

顺便说一句,C和C++的标准语法文件不能覆盖之前定义的新语法文件。在定义高亮方案时,有时候会有一些奇怪的优先规则。但是,如果出现问题,您将不得不与插件维护人员一起查看。无论如何,我相信你已经按照它的意图安装/激活了插件。 –