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 附帶的突出顯示)實際上有效,但縮排無效。

我認為病原體不載入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 檔案就很好。

相關內容