2013-03-22 88 views
1

如何防止在命令行vim中加載插件,但允許它在gvim中加載?僅適用於gvim的插件?

我試圖用gitgutter,它有這些線在頂部:

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

然而,每次我啓動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說法是正確和工作,但有gitgutter在我捆/目錄拷貝被裝載在地方plugin/gitgutter.vim

回答

1

你應該是測試has('signs')而不是has('gui_running')

:h +signs 
+0

添加此測試沒有效果;我認爲這個問題可能與我對gui_running標誌的測試不同,但是finish命令似乎被忽略了。 – keflavich 2013-03-22 17:57:45

+1

我發現奇怪的是,vim告訴你':sign'在你的vim版本中不被支持。 ':echo有('符號')'告訴你什麼?我想你會看到0,這應該導致執行完成。不要猶豫,在你的插件中添加':echomsg'的痕跡。你會很快看到你的假設是錯誤的。 – 2013-03-22 18:21:55

+0

'if'語句肯定應該評估爲'true':'has('gui_running')'和'has('signs')'都是0,但是我仍然得到'E319'消息。 – keflavich 2013-03-22 20:00:23