vim-go -> vim-golang

This commit is contained in:
Adam Stankiewicz 2013-09-12 17:22:37 +02:00
parent 35433aa23c
commit 4c2025af5c
6 changed files with 30 additions and 115 deletions

View File

@ -34,7 +34,7 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
if executable('go') if executable('go')
let goroot = substitute(system('go env GOROOT'), '\n', '', 'g') let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
if v:shell_error if v:shell_error
echomsg '\'go env GOROOT\' failed' echo '\'go env GOROOT\' failed'
endif endif
else else
let goroot = $GOROOT let goroot = $GOROOT
@ -44,11 +44,7 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
let dirs += [ goroot ] let dirs += [ goroot ]
endif endif
let pathsep = ':' let workspaces = split($GOPATH, ':')
if s:goos == 'windows'
let pathsep = ';'
endif
let workspaces = split($GOPATH, pathsep)
if workspaces != [] if workspaces != []
let dirs += workspaces let dirs += workspaces
endif endif
@ -60,19 +56,16 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
let ret = {} let ret = {}
for dir in dirs for dir in dirs
" this may expand to multiple lines let root = expand(dir . '/pkg/' . s:goos . '_' . s:goarch)
let root = split(expand(dir . '/pkg/' . s:goos . '_' . s:goarch), "\n") for i in split(globpath(root, a:ArgLead.'*'), "\n")
for r in root
for i in split(globpath(r, a:ArgLead.'*'), "\n")
if isdirectory(i) if isdirectory(i)
let i .= '/' let i .= '/'
elseif i !~ '\.a$' elseif i !~ '\.a$'
continue continue
endif endif
let i = substitute(substitute(i[len(r)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g') let i = substitute(substitute(i[len(root)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
let ret[i] = i let ret[i] = i
endfor endfor
endfor endfor
endfor
return sort(keys(ret)) return sort(keys(ret))
endfunction endfunction

View File

@ -53,7 +53,7 @@ syntax 'slim-template/vim-slim' &
syntax 'vim-scripts/XSLT-syntax' & syntax 'vim-scripts/XSLT-syntax' &
syntax 'vim-scripts/python.vim--Vasiliev' & syntax 'vim-scripts/python.vim--Vasiliev' &
syntax 'vim-scripts/octave.vim--' & syntax 'vim-scripts/octave.vim--' &
syntax 'uggedal/go-vim' & syntax 'jnwhiteh/vim-golang' &
syntax 'spf13/PIV' & syntax 'spf13/PIV' &
syntax 'briancollins/vim-jst' & syntax 'briancollins/vim-jst' &
syntax 'derekwyatt/vim-scala' & syntax 'derekwyatt/vim-scala' &

View File

@ -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 <args>
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

View File

@ -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

View File

@ -12,25 +12,11 @@
" It tries to preserve cursor position and avoids " It tries to preserve cursor position and avoids
" replacing the buffer with stderr output. " 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") if exists("b:did_ftplugin_go_fmt")
finish finish
endif 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() command! -buffer Fmt call s:GoFormat()
endif
function! s:GoFormat() function! s:GoFormat()
let view = winsaveview() let view = winsaveview()

View File

@ -24,40 +24,23 @@
" imported, an error will be displayed and the buffer will be " imported, an error will be displayed and the buffer will be
" untouched. " 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 " \f - Runs :Import fmt
" au Filetype go nnoremap <buffer> <LocalLeader>f :Import fmt<CR> " \F - Runs :Drop fmt
" "
" Drop fmt " The backslash is the default maplocalleader, so it is possible that
" au Filetype go nnoremap <buffer> <LocalLeader>F :Drop fmt<CR>
"
" Import the word under your cursor
" au Filetype go nnoremap <buffer> <LocalLeader>k
" \ :exe 'Import ' . expand('<cword>')<CR>
"
" 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).
" "
" Options:
"
" g:go_import_commands [default=1]
"
" Flag to indicate whether to enable the commands listed above.
"
if exists("b:did_ftplugin_go_import") if exists("b:did_ftplugin_go_import")
finish finish
endif 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, '', <f-args>) command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', <f-args>)
command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>) command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>)
command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>) command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>)
endif 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 view = winsaveview()