Pathogen - 仅有部分 vim 插件有效

Pathogen - 仅有部分 vim 插件有效

所以最近我安装了 Pathogen 以及一些插件,如 NerdTree 和 Solarized,它们都运行得很好。

今天我尝试安装 Ruby 缩进插件(https://github.com/jelera/vim-javascript-syntax) 但不幸的是它不起作用。

然后我继续尝试安装 Javascript 缩进/语法高亮插件(https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport),有趣的是——高级语法高亮(不是 solarized 自带的那个)实际上有效,但缩进无效。

我认为 Pathogen 不会加载ftplugin文件夹。输出如下:scriptnames

  1: /usr/share/vim/vimrc
  2: /usr/share/vim/vim74/debian.vim
  3: /usr/share/vim/vim74/syntax/syntax.vim
  4: /usr/share/vim/vim74/syntax/synload.vim
  5: /usr/share/vim/vim74/syntax/syncolor.vim
  6: /usr/share/vim/vim74/filetype.vim
  7: ~/.vimrc
  8: ~/.vim/autoload/pathogen.vim
  9: /usr/share/vim/vim74/ftoff.vim
 10: ~/.vim/bundle/vim-javascript/ftdetect/javascript.vim
 11: ~/.vim/bundle/vim-ruby/ftdetect/ruby.vim
 12: /usr/share/vim/vim74/syntax/nosyntax.vim
 13: /usr/share/vim/vim74/ftplugin.vim
 14: /usr/share/vim/vim74/indent.vim
 15: /usr/share/vim/vim74/macros/matchit.vim
 16: ~/.vim/bundle/vim-colors-solarized/colors/solarized.vim
 17: ~/.vim/bundle/MatchTagAlways/plugin/MatchTagAlways.vim
 18: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim
 19: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim
 20: ~/.vim/bundle/nerdtree/lib/nerdtree/path.vim
 21: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim
 22: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim
 23: ~/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim
 24: ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim
 25: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim
 26: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim
 27: ~/.vim/bundle/nerdtree/lib/nerdtree/opener.vim
 28: ~/.vim/bundle/nerdtree/lib/nerdtree/creator.vim
 29: ~/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim
 30: ~/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim
 31: ~/.vim/bundle/nerdtree/lib/nerdtree/ui.vim
 32: ~/.vim/bundle/nerdtree/lib/nerdtree/event.vim
 33: ~/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim
 34: ~/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim
 35: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim
 36: ~/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim
 37: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
 38: /usr/share/vim/vim74/plugin/gzip.vim
 39: /usr/share/vim/vim74/plugin/matchparen.vim
 40: /usr/share/vim/vim74/plugin/netrwPlugin.vim
 41: /usr/share/vim/vim74/plugin/rrhelper.vim
 42: /usr/share/vim/vim74/plugin/spellfile.vim
 43: /usr/share/vim/vim74/plugin/tarPlugin.vim
 44: /usr/share/vim/vim74/plugin/tohtml.vim
 45: /usr/share/vim/vim74/plugin/vimballPlugin.vim
 46: /usr/share/vim/vim74/plugin/zipPlugin.vim

以下是我的.vimrc文件的第一行:

     execute pathogen#infect()
     syntax on
     filetype plugin indent on

我注意到所有包含plugin文件夹的插件都可以工作,而只有文件夹的插件则ftplugin不行。如能得到任何帮助,我将不胜感激!

编辑:

我刚刚发现,如果我将 ruby​​ 的插件文件夹放在plugin文件夹中,bundle它就会正确显示在:scriptnames列表中。

 16: ~/.vim/plugin/vim-ruby/autoload/rubycomplete.vim
 17: ~/.vim/plugin/vim-ruby/compiler/eruby.vim
 18: ~/.vim/plugin/vim-ruby/compiler/rake.vim
 19: ~/.vim/plugin/vim-ruby/compiler/rspec.vim
 20: ~/.vim/plugin/vim-ruby/compiler/ruby.vim
 21: ~/.vim/plugin/vim-ruby/compiler/rubyunit.vim
 22: ~/.vim/plugin/vim-ruby/ftdetect/ruby.vim
 23: ~/.vim/plugin/vim-ruby/ftplugin/eruby.vim

并引发以下错误:

Error: Rubycomplete requires vim compiled with +ruby
Error: falling back to syntax completion

但缩进仍然不起作用。

答案1

您的脚本名甚至不包含通常的内置 ftplugin 或语法文件(无论是 ruby​​ 还是 javascript)。

所以我的猜测是你没有编辑 ruby​​ 或 javascript 文件。或者,如果你正在编辑,Vim 没有检测到该文件是 ruby​​ 或 javascript。

您可以尝试手动将文件类型设置为 ruby​​ 或 javascript,或者尝试找出为什么您的 Vim 无法正确检测它们。您可能没有使用自动文件类型检测支持的文件扩展名。您可以根据需要添加新的文件扩展名 (:help new-filetype);但无论如何,Pathogen 可以很好地加载 ftplugin 文件。

相关内容