]> Cypherpunks repositories - gostls13.git/commitdiff
misc/vim: Define import commands on buffer switch
authorGustavo Niemeyer <gustavo@niemeyer.net>
Tue, 1 Feb 2011 00:12:57 +0000 (11:12 +1100)
committerAndrew Gerrand <adg@golang.org>
Tue, 1 Feb 2011 00:12:57 +0000 (11:12 +1100)
This change fixes the import plugin so that the
defined commands are available when opening a new
Go buffer from within Vim itself.

R=adg, rsc
CC=golang-dev
https://golang.org/cl/3998053

misc/vim/ftplugin/go/import.vim

index 494414962a378bf83d2dbaa63603ca8f4839e81a..b5814ca5dff4d7c7fca3cbd009f33b7e58e25d50 100644 (file)
 " The backslash is the default maplocalleader, so it is possible that
 " your vim is set to use a different character (:help maplocalleader).
 "
-
-if exists("s:loaded") || exists("b:did_ftplugin")
+if exists("b:did_ftplugin")
     finish
 endif
-let s:loaded = 1
 
 command! -buffer -nargs=? Drop call s:SwitchImport(0, '', <f-args>)
 command! -buffer -nargs=1 Import call s:SwitchImport(1, '', <f-args>)
@@ -44,7 +42,7 @@ command! -buffer -nargs=* ImportAs call s:SwitchImport(1, <f-args>)
 map <buffer> <LocalLeader>f :Import fmt<CR>
 map <buffer> <LocalLeader>F :Drop fmt<CR>
 
-function s:SwitchImport(enabled, localname, path)
+function! s:SwitchImport(enabled, localname, path)
     let view = winsaveview()
     let path = a:path
 
@@ -196,7 +194,7 @@ function s:SwitchImport(enabled, localname, path)
 
 endfunction
 
-function s:Error(s)
+function! s:Error(s)
     echohl Error | echo a:s | echohl None
 endfunction