Skip to content

Commit 83c3878

Browse files
committed
Move file detection to ftdetect & fix global usage.
Use fallback to $GOROOT if g:golang_goroot variable is not set.
1 parent 2b2dbdf commit 83c3878

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Just clone this repo into your bundles directory:
1010

1111
git clone https://github.com/rjohnsondev/vim-compiler-go.git ~/.vim/bundle/vim-compiler-go
1212

13+
Either ensure the $GOROOT environment variable is set, or otherwise set the
14+
g:golang_goroot variable in .vimrc to where your go installation can be found.
15+
This must be an absolute path:
16+
17+
let g:golang_goroot = "/home/richard/go"
18+
1319
### Manual installation
1420

1521
Drop golang.vim in ~/.vim/compiler directory.

Diff for: ftdetect/go.vim

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
autocmd FileType go compiler golang

Diff for: ftplugin/go.vim

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
autocmd FileType go compiler golang
2-
let g:golang_goroot = $GOROOT
1+
if !empty($GOROOT) && !exists('g:golang_goroot')
2+
let g:golang_goroot = $GOROOT
3+
endif
4+
if !exists('g:golang_goroot')
5+
let g:golang_goroot = '/usr/bin'
6+
echoerr 'Please set $GOROOT or g:golang_goroot'
7+
endif

0 commit comments

Comments
 (0)