From 30c1920e4fa4e612238e1f435907c40ecfa47f33 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sat, 2 Nov 2013 23:27:57 +0100 Subject: Massive update :) --- ftplugin/go/import.vim | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'ftplugin/go/import.vim') diff --git a/ftplugin/go/import.vim b/ftplugin/go/import.vim index 1d969e46..91c8697a 100644 --- a/ftplugin/go/import.vim +++ b/ftplugin/go/import.vim @@ -24,23 +24,40 @@ " imported, an error will be displayed and the buffer will be " untouched. " -" In addition to these commands, there are also two shortcuts mapped: +" If you would like to add shortcuts, you can do so by doing the following: " -" \f - Runs :Import fmt -" \F - Runs :Drop fmt +" Import fmt +" au Filetype go nnoremap f :Import fmt " -" The backslash is the default maplocalleader, so it is possible that +" Drop fmt +" au Filetype go nnoremap F :Drop fmt +" +" Import the word under your cursor +" au Filetype go nnoremap k +" \ :exe 'Import ' . expand('') +" +" The backslash '\' is the default maplocalleader, so it is possible that " your vim is set to use a different character (:help maplocalleader). " +" Options: +" +" g:go_import_commands [default=1] +" +" Flag to indicate whether to enable the commands listed above. +" if exists("b:did_ftplugin_go_import") finish endif -command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', ) -command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', ) -command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, ) -map f :Import fmt -map F :Drop fmt +if !exists("g:go_import_commands") + let g:go_import_commands = 1 +endif + +if g:go_import_commands + command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', ) + command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', ) + command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, ) +endif function! s:SwitchImport(enabled, localname, path) let view = winsaveview() -- cgit v1.2.3