我正在使用病原体来管理我在 vim 中的插件,并且我的 vimrc 中有一个部分,只有在未安装/不会加载某个插件时我才想运行该部分。例如
if(dwm.vim not in use)
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
endif
在大多数情况下可能会起作用的两个选项是检查 dwm.vim 是否在g:pathogen_disabled
和/或检查目录是否.vim/bundle/dwm.vim
存在。
然而,这些检查似乎有些脆弱。例如,如果我根本没有 dwm,则检查 dwm.vim 不禁用病原体是不够的,并且无论出于何种原因 dwm.vim 位于某个非标准位置,但仍使其进入runtimepath
路径检查将不起作用.
The whole point of pathogen is to make managing my runtimepath
easier, so an elegant solution would be to search this path. But searching the help, the pathogen source, google, and here revealed no easy way to do this. Can I do this in vim/pathogen natively? Is there a plugin that will do this for me? Should I not be doing this at all, since the cases where the checks fail are fairly corner-casey and won't happen as long as I manage my plugins properly?