我试图使用Pathogen
来管理Vim插件。我在.vim/ftplugins
中写了几个脚本。
我安装了病原体,但现在ftplugins中没有一个脚本运行。
我试着用脚本在.vim/bundle
内添加一个目录,但它不起作用(它是.vim/bundle/local/ftplugin/python.vim
)
任何想法我怎么能使病原体加载脚本在ftplugin目录?
我的.vimrc
第一行:
set nocompatible
syntax on
filetype plugin indent on
"execute pathogen#infect()
只适用于注释掉的行
我从Bash提示符中运行gvim
,文件名作为第一个参数,如下所示:
$ gvim some/path/somefile.py
我希望看到的文件与我预定义的配色方案的Python文件定义在~/.vim/ftplugin/Python。Vim和脚本中定义的所有其他设置
~/。Vim/bundle目录为空
病原体在~/中。Vim/autoload,没有别的了。
$ ls ~/.vim/ftplugin/
css.vim html.vim javascript.vim python_pep8.vim python_pyflakes.vim python.vim rst.vim xml.vim
$ ls ~/.vim
autoload bundle colors doc ftdetect ftplugin plugins ScrollColor.vim spell syntax
文件类型检测有问题,这是病原体问题。
在我的情况下的工作很简单,使用这个来启用病原体:
set nocompatible
"execute pathogen#infect() " breaks filetype detection
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
syntax on
我所做的就是删除我的~/。Vim目录并从一个干净的目录开始。一项一项地添加,然后检查结果。我意识到它没有检测到正确的文件类型(当我打开一个空文件检测是可以的,但它不是打开一个现有的文件)。
把我的评论放在这里:
想知道它是否工作,如果你把:filetype
和:syntax
呼叫后:execute
?官方README
建议在第二部分这样做:第一个:execute
,第二个:syntax
,第三个:filetype
。注意:不要像@Eduan建议的那样在:execute
之前禁用文件类型,只是不要在:execute
被调用之前启用它:
set nocompatible
execute pathogen#infect()
syntax on
filetype plugin indent on
另外,千万不要用*map
。
我想我能看到你的问题,把它放在一个答案,而不是一个注释为了示例代码的清晰度。
试试这个:
" Set the filetype stuff to off, required for Pathogen
filetype off
filetype plugin indent off
execute pathogen#infect()
" You can now turn it on again
filetype on
filetype plugin indent on