mirror of
https://github.com/golang/go
synced 2024-11-22 01:44:40 -07:00
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
This commit is contained in:
parent
400d7772cc
commit
5887ef7571
@ -32,11 +32,9 @@
|
|||||||
" The backslash is the default maplocalleader, so it is possible that
|
" The backslash is the default maplocalleader, so it is possible that
|
||||||
" your vim is set to use a different character (:help maplocalleader).
|
" your vim is set to use a different character (:help maplocalleader).
|
||||||
"
|
"
|
||||||
|
if exists("b:did_ftplugin")
|
||||||
if exists("s:loaded") || exists("b:did_ftplugin")
|
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let s:loaded = 1
|
|
||||||
|
|
||||||
command! -buffer -nargs=? Drop call s:SwitchImport(0, '', <f-args>)
|
command! -buffer -nargs=? Drop call s:SwitchImport(0, '', <f-args>)
|
||||||
command! -buffer -nargs=1 Import call s:SwitchImport(1, '', <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 :Import fmt<CR>
|
||||||
map <buffer> <LocalLeader>F :Drop 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 view = winsaveview()
|
||||||
let path = a:path
|
let path = a:path
|
||||||
|
|
||||||
@ -196,7 +194,7 @@ function s:SwitchImport(enabled, localname, path)
|
|||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function s:Error(s)
|
function! s:Error(s)
|
||||||
echohl Error | echo a:s | echohl None
|
echohl Error | echo a:s | echohl None
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user