仅适用于gvim的插件?

时间:2013-03-22 16:50:47

标签: vim

如何阻止插件在命令行vim中加载,但允许在gvim中加载?

我正在尝试使用gitgutter,这些行位于顶部:

    if exists('g:loaded_gitgutter') || !executable('git') ||  !has("gui_running") || &cp
       finish
    endif

但是,每次我在启用git的目录中的命令行启动vim时,我都会得到所有这些垃圾:

"plugin/gitgutter.vim" 416L, 11964C
Error detected while processing function GitGutter..<SNR>35_init..<SNR>35_define_signs:
line    7:
E319: Sorry, the command is not available in this version:     sign define GitGutterLineAdded           text=+  texthl=lineAdded    linehl=NONE
line    8:
E319: Sorry, the command is not available in this version:     sign define GitGutterLineModified        text=~  texthl=lineModified linehl=NONE
line    9:
E319: Sorry, the command is not available in this version:     sign define GitGutterLineRemoved         text=_  texthl=lineRemoved  linehl=NONE
line   10:
E319: Sorry, the command is not available in this version:     sign define GitGutterLineModifiedRemoved text=~_ texthl=lineModified linehl=NONE
Error detected while processing function GitGutter..<SNR>35_find_other_signs:
line    2:
E319: Sorry, the command is not available in this version: :sign place file=/Users/adam/.vim/plugin/gitgutter.vim
Error detected while processing function GitGutter..<SNR>35_show_signs..<SNR>35_add_sign:
line    3:
E319: Sorry, the command is not available in this version: :sign place 3000 line=1 name=GitGutterLineModified file=/Users/adam/.vim/plugin/gitgutter.vim

我做错了什么?

编辑:我的问题有点无效 - 事实证明,我编辑的if语句既正确又有效,但我的bundle /目录中有一个gitgutter的副本正在加载{{1 }}

1 个答案:

答案 0 :(得分:1)

您应该测试has('signs')而不是has('gui_running')

:h +signs