diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2011-02-01 11:12:57 +1100 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2011-02-01 11:12:57 +1100 |
commit | 5887ef75713e3f3291f7880809ae2b91c9944ce9 (patch) | |
tree | 3ea3d7205f990ae40ec9a636f1a9a6156c0c9baf | |
parent | 400d7772cc7f990f93330d3652545147f60ff3cb (diff) | |
download | go-5887ef75713e3f3291f7880809ae2b91c9944ce9.tar.gz go-5887ef75713e3f3291f7880809ae2b91c9944ce9.zip |
misc/vim: Define import commands on buffer switch
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
-rw-r--r-- | misc/vim/ftplugin/go/import.vim | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/misc/vim/ftplugin/go/import.vim b/misc/vim/ftplugin/go/import.vim index 494414962a..b5814ca5df 100644 --- a/misc/vim/ftplugin/go/import.vim +++ b/misc/vim/ftplugin/go/import.vim @@ -32,11 +32,9 @@ " 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 |