Skip to content

Commit

Permalink
separate "go env ROOT"
Browse files Browse the repository at this point in the history
  • Loading branch information
koron committed Jul 16, 2016
1 parent 522fc49 commit b1ab840
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 1 addition & 8 deletions autoload/go/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
return go#complete#PackageMembers(words[1], words[2])
endif

if executable('go')
let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
if v:shell_error
echomsg '''go env GOROOT'' failed'
endif
else
let goroot = $GOROOT
endif
let goroot = go#env#root()

if len(goroot) != 0 && isdirectory(goroot)
let dirs += [goroot]
Expand Down
11 changes: 11 additions & 0 deletions autoload/go/env.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function! go#env#root()
if executable('go')
let root = substitute(system('go env GOROOT'), '\n', '', 'g')
if v:shell_error
echomsg '''go env GOROOT'' failed'
endif
else
let root = $GOROOT
endif
return root
endfunction

0 comments on commit b1ab840

Please sign in to comment.