From 4c2025af5cee3fcd08321c2f23c38e460d3991a9 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 12 Sep 2013 17:22:37 +0200 Subject: [PATCH] vim-go -> vim-golang --- autoload/go/complete.vim | 45 +++++++++++++++++----------------------- build.sh | 2 +- compiler/go.vim | 30 --------------------------- ftplugin/go.vim | 17 --------------- ftplugin/go/fmt.vim | 16 +------------- ftplugin/go/import.vim | 35 ++++++++----------------------- 6 files changed, 30 insertions(+), 115 deletions(-) delete mode 100644 compiler/go.vim delete mode 100644 ftplugin/go.vim diff --git a/autoload/go/complete.vim b/autoload/go/complete.vim index 80fa451..cc1013b 100644 --- a/autoload/go/complete.vim +++ b/autoload/go/complete.vim @@ -32,46 +32,39 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos) let dirs = [] if executable('go') - let goroot = substitute(system('go env GOROOT'), '\n', '', 'g') - if v:shell_error - echomsg '\'go env GOROOT\' failed' - endif + let goroot = substitute(system('go env GOROOT'), '\n', '', 'g') + if v:shell_error + echo '\'go env GOROOT\' failed' + endif else - let goroot = $GOROOT + let goroot = $GOROOT endif if len(goroot) != 0 && isdirectory(goroot) - let dirs += [goroot] + let dirs += [ goroot ] endif - let pathsep = ':' - if s:goos == 'windows' - let pathsep = ';' - endif - let workspaces = split($GOPATH, pathsep) + let workspaces = split($GOPATH, ':') if workspaces != [] - let dirs += workspaces + let dirs += workspaces endif if len(dirs) == 0 - " should not happen - return [] + " should not happen + return [] endif let ret = {} for dir in dirs - " this may expand to multiple lines - let root = split(expand(dir . '/pkg/' . s:goos . '_' . s:goarch), "\n") - for r in root - for i in split(globpath(r, a:ArgLead.'*'), "\n") - if isdirectory(i) - let i .= '/' - elseif i !~ '\.a$' - continue - endif - let i = substitute(substitute(i[len(r)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g') - let ret[i] = i - endfor + let root = expand(dir . '/pkg/' . s:goos . '_' . s:goarch) + for i in split(globpath(root, a:ArgLead.'*'), "\n") + if isdirectory(i) + let i .= '/' + elseif i !~ '\.a$' + continue + endif + let i = substitute(substitute(i[len(root)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g') + let ret[i] = i endfor endfor return sort(keys(ret)) diff --git a/build.sh b/build.sh index bbc57c3..138a1f8 100755 --- a/build.sh +++ b/build.sh @@ -53,7 +53,7 @@ syntax 'slim-template/vim-slim' & syntax 'vim-scripts/XSLT-syntax' & syntax 'vim-scripts/python.vim--Vasiliev' & syntax 'vim-scripts/octave.vim--' & -syntax 'uggedal/go-vim' & +syntax 'jnwhiteh/vim-golang' & syntax 'spf13/PIV' & syntax 'briancollins/vim-jst' & syntax 'derekwyatt/vim-scala' & diff --git a/compiler/go.vim b/compiler/go.vim deleted file mode 100644 index 2c8cce4..0000000 --- a/compiler/go.vim +++ /dev/null @@ -1,30 +0,0 @@ -" Copyright 2013 The Go Authors. All rights reserved. -" Use of this source code is governed by a BSD-style -" license that can be found in the LICENSE file. -" -" compiler/go.vim: Vim compiler file for Go. - -if exists("current_compiler") - finish -endif -let current_compiler = "go" - -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal -endif - -let s:save_cpo = &cpo -set cpo-=C - -CompilerSet makeprg=go\ build -CompilerSet errorformat= - \%-G#\ %.%#, - \%A%f:%l:%c:\ %m, - \%A%f:%l:\ %m, - \%C%*\\s%m, - \%-G%.%# - -let &cpo = s:save_cpo -unlet s:save_cpo - -" vim:ts=4:sw=4:et diff --git a/ftplugin/go.vim b/ftplugin/go.vim deleted file mode 100644 index 8066733..0000000 --- a/ftplugin/go.vim +++ /dev/null @@ -1,17 +0,0 @@ -" Copyright 2013 The Go Authors. All rights reserved. -" Use of this source code is governed by a BSD-style -" license that can be found in the LICENSE file. -" -" go.vim: Vim filetype plugin for Go. - -if exists("b:did_ftplugin") - finish -endif -let b:did_ftplugin = 1 - -setlocal comments=s1:/*,mb:*,ex:*/,:// -setlocal commentstring=//\ %s - -let b:undo_ftplugin = "setl com< cms<" - -" vim:ts=4:sw=4:et diff --git a/ftplugin/go/fmt.vim b/ftplugin/go/fmt.vim index 5447d45..30814fd 100644 --- a/ftplugin/go/fmt.vim +++ b/ftplugin/go/fmt.vim @@ -12,25 +12,11 @@ " It tries to preserve cursor position and avoids " replacing the buffer with stderr output. " -" Options: -" -" g:go_fmt_commands [default=1] -" -" Flag to indicate whether to enable the commands listed above. -" if exists("b:did_ftplugin_go_fmt") finish endif - -if !exists("g:go_fmt_commands") - let g:go_fmt_commands = 1 -endif - - -if g:go_fmt_commands - command! -buffer Fmt call s:GoFormat() -endif +command! -buffer Fmt call s:GoFormat() function! s:GoFormat() let view = winsaveview() diff --git a/ftplugin/go/import.vim b/ftplugin/go/import.vim index 91c8697..1d969e4 100644 --- a/ftplugin/go/import.vim +++ b/ftplugin/go/import.vim @@ -24,40 +24,23 @@ " imported, an error will be displayed and the buffer will be " untouched. " -" If you would like to add shortcuts, you can do so by doing the following: +" In addition to these commands, there are also two shortcuts mapped: " -" Import fmt -" au Filetype go nnoremap f :Import fmt +" \f - Runs :Import fmt +" \F - Runs :Drop fmt " -" 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 +" 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 -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 +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 function! s:SwitchImport(enabled, localname, path) let view = winsaveview()