Vim-go: Syntastic + packages in gb path.

Created on 22 Nov 2015  ยท  3Comments  ยท  Source: fatih/vim-go

I'm working on a gb project, and while :GoPath reports the correct folder(gb project) echo $GOPATH reports the default $GOPATH. This is causing syntastic to fail with "package not found in path" error whenever there is an import of another gb package(from the same project folder).

This issue is specific to syntastic. Using GoBuild does not cause any errors.

I also noticed that my gb path contains both pkg paths named darwin-amd64 and darwin_amd64.

My environment:
Shell - ZSH(GOPATH defined in zshrc)
editor - nvim

nvimrc:

filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'fatih/vim-go'
Plugin 'tpope/vim-sensible'
Plugin 'tpope/vim-fugitive'
Plugin 'Valloric/YouCompleteMe'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'markcornick/vim-terraform'
Plugin 'robbles/logstash.vim'
Plugin 'jeffkreeftmeijer/vim-numbertoggle'
Plugin 'scrooloose/syntastic'
Plugin 'rodjek/vim-puppet'
Plugin 'tomtom/tcomment_vim'
Plugin 'mxw/vim-jsx'
Plugin 'rizzatti/dash.vim'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'edsono/vim-matchit'


" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"
"My Config
"
"
let mapleader = ","
set rnu
syntax enable
let g:rehash256 = 1
let g:go_fmt_command = "goimports"
set splitright

set tabstop=4       " The width of a TAB is set to 4.
                    " Still it is a \t. It is just that
                    " Vim will interpret it to be having
                    " a width of 4.

set shiftwidth=4    " Indents will have a width of 4

set softtabstop=4   " Sets the number of columns for a TAB

set expandtab       " Expand TABs to spaces

nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

gb project folder structure:

.
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ Dockerfile.build
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ bin
โ”‚ย ย  โ””โ”€โ”€ planc
โ”œโ”€โ”€ db
โ”‚ย ย  โ”œโ”€โ”€ dbconf.yml
โ”‚ย ย  โ”œโ”€โ”€ dev.db
โ”‚ย ย  โ””โ”€โ”€ migrations
โ”œโ”€โ”€ pkg
โ”‚ย ย  โ”œโ”€โ”€ darwin-amd64
โ”‚ย ย  โ””โ”€โ”€ darwin_amd64
โ”œโ”€โ”€ src
โ”‚ย ย  โ””โ”€โ”€ planc
โ””โ”€โ”€ vendor
    โ”œโ”€โ”€ manifest
    โ”œโ”€โ”€ pkg
    โ””โ”€โ”€ src

Most helpful comment

@groob I have got exactly the same issue. Syntastic calls go build which is unaware of the gopath which vim-go sets.

It would be great if @fatih considered overwriting $GOPATH once vim-go successfully detected it.

As a workaround, I added the following to my vim configuration:

au FileType go let $GOPATH = go#path#Detect()

All 3 comments

Hi @groob I'm not responsible of Syntastic. If you have a problem with vim-go please let me know, otherwise I don't have much to do or say here.

@groob I have got exactly the same issue. Syntastic calls go build which is unaware of the gopath which vim-go sets.

It would be great if @fatih considered overwriting $GOPATH once vim-go successfully detected it.

As a workaround, I added the following to my vim configuration:

au FileType go let $GOPATH = go#path#Detect()

@vaijab I wrote a gb syntax checker, but the PR was rejected from syntactic, even though it works fine with gb and vim.

If you'd like to use it, you can download it and add it your folder under syntax checkers https://github.com/groob/syntastic/blob/gb_checker/syntax_checkers/go/gb.vim

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wpaulino picture wpaulino  ยท  4Comments

MattFlower picture MattFlower  ยท  4Comments

danielmanesku picture danielmanesku  ยท  4Comments

orlangure picture orlangure  ยท  3Comments

derekchiang picture derekchiang  ยท  3Comments