I was trying to add the functionality that a plugin in vim statically analyses my current go (golang) file and catches errors.
What I tried was doing the instructions in the readme.txt file in $GOROOT/misc/vim
. There it had the following suggestion:
Vim compiler plugin
-------------------
To install the compiler plugin:
1. Same as 1 above.
2. Copy or link compiler/go.vim to the compiler directory underneath your vim
runtime directory (normally $HOME/.vim/compiler).
3. Activate the compiler plugin with ":compiler go". To always enable the
compiler plugin in Go source files add an autocommand to your .vimrc file
(normally $HOME/.vimrc):
autocmd FileType go compiler go
Godoc plugin
------------
I did all they said but:
autocmd FileType go compiler go
doesn't do anything when I save my file. What is it supposed to do? I clearly have errors in my code:
package main
import "fmt"
//This is my first go program!
//cool hu? Hope I can render this.
func main(){
jhjkahsdjkh //<-----------------ERROR HERE
fmt.Print("Hello World
")
}
I don't know what to expect cuz I don't know what autocmd FileType go compiler go
is supposed to do.
This is how my vim file looks like:
set nocompatible " be iMproved, required
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'
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
Plugin 'user/L9', {'name': 'newL9'}
Plugin 'commentary.vim'
"Plugin 'fatih/vim-go'
"Plugin 'Syntastic'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
""""------------------------------------
syntax on
" filetype plugin on
" filetype indent on
autocmd FileType go compiler go
" autocmd FileType go autocmd BufWritePre <buffer> Fmt
I also tried this by installing 'fatih/vim-go' plugin and doing the command :GoBuild
. That kind of worked, but instead of pointing me to my errors in the current file in went to other files in other packages to that are in development and obviously have errors, but I don't want to see those, I only want to see the errors in my current file. Is there a plugin that does this? Is there a way for my vim to do this on save or something?