mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated vim plugins
This commit is contained in:
@ -33,7 +33,7 @@ function! go#package#Paths() abort
|
||||
|
||||
if !exists("s:goroot")
|
||||
if executable('go')
|
||||
let s:goroot = go#util#goroot()
|
||||
let s:goroot = go#util#env("goroot")
|
||||
if go#util#ShellError() != 0
|
||||
echomsg '''go env GOROOT'' failed'
|
||||
endif
|
||||
@ -54,29 +54,25 @@ function! go#package#Paths() abort
|
||||
return dirs
|
||||
endfunction
|
||||
|
||||
function! go#package#ImportPath(arg) abort
|
||||
let path = fnamemodify(resolve(a:arg), ':p')
|
||||
let dirs = go#package#Paths()
|
||||
|
||||
for dir in dirs
|
||||
if len(dir) && matchstr(escape(path, '\/'), escape(dir, '\/')) == 0
|
||||
let workspace = dir
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !exists('workspace')
|
||||
" ImportPath returns the import path in the current directory it was executed
|
||||
function! go#package#ImportPath() abort
|
||||
let out = go#tool#ExecuteInDir("go list")
|
||||
if go#util#ShellError() != 0
|
||||
return -1
|
||||
endif
|
||||
|
||||
if go#util#IsWin()
|
||||
let srcdir = substitute(workspace . '\src\', '//', '/', '')
|
||||
return path[len(srcdir):]
|
||||
else
|
||||
let srcdir = substitute(workspace . '/src/', '//', '/', '')
|
||||
return substitute(path, srcdir, '', '')
|
||||
let import_path = split(out, '\n')[0]
|
||||
|
||||
" go list returns '_CURRENTDIRECTORY' if the directory is not inside GOPATH.
|
||||
" Check it and retun an error if that is the case
|
||||
if import_path[0] ==# '_'
|
||||
return -1
|
||||
endif
|
||||
|
||||
return import_path
|
||||
endfunction
|
||||
|
||||
|
||||
function! go#package#FromPath(arg) abort
|
||||
let path = fnamemodify(resolve(a:arg), ':p')
|
||||
let dirs = go#package#Paths()
|
||||
|
Reference in New Issue
Block a user