Skip to content

Instantly share code, notes, and snippets.

@t-yuki
Last active December 27, 2015 13:58
Show Gist options
  • Save t-yuki/7336666 to your computer and use it in GitHub Desktop.
Save t-yuki/7336666 to your computer and use it in GitHub Desktop.
My vimrc on Windows and Linux for golang. **MOVED TO https://github.com/t-yuki/vimfiles**
:Lint -> execute golint
:Fmt -> execute gofmt
:Import xxx -> add import declaration xxx
:w -> write file and execute gofmt and golint
\r -> do quickrun. to close, type :on or :only
<C-X><C-O> -> autocomple by gocode
# Setup for Go 1.2rc3
# before setup, you should install Go and set GOPATH env
### Linux
mkdir -p ~/.vim/{backup,undo,tmp}
go get -u github.com/nsf/gocode
go get -u github.com/golang/lint/...
git clone https://github.com/thinca/vim-quickrun ~/.vim/vim-quickrun
### Windows
go get -u -ldflags -H=windowsgui github.com/nsf/gocode
go get -u -ldflags -H=windowsgui github.com/golang/lint/...
git clone https://github.com/thinca/vim-quickrun %HOMEPATH%/_vim/vim-quickrun
# sendto: %APPDATA%\Microsoft\Windows\SendTo
# gvim -> gvim.exe -p
# gvimcli -> gvim.exe -p --remote-tab-silent
# refs (japanese)
# http://qiita.com/todogzm/items/3c281da10287f7383487
# http://mattn.kaoriya.net/software/vim/20130531000559.htm
# http://golang.org/misc/vim/readme.txt?m=text
let s:running_windows = has("win16") || has("win32") || has("win64")
if s:running_windows
set backupdir=~/_vim/backup
set undodir=~/_vim/undo
set directory=~/_vim//tmp
else
set backupdir=~/.vim/backup
set undodir=~/.vim/undo
set directory=~/.vim/tmp
endif
set showtabline=2
"set number
"autocmd BufAdd,BufNewFile * nested tab sball
filetype off
filetype plugin indent off
"quickrun
if s:running_windows
set runtimepath+=$HOME/_vim/vim-quickrun
else
set runtimepath+=~/.vim/vim-quickrun
endif
let g:quickrun_config={'*': {'split': ':botright 4sp'}}
let g:quickrun_config.go={'command': 'go', 'exec': '%c test'}
"misc/vim
set runtimepath+=$GOROOT/misc/vim
auto FileType go set makeprg=go\ test\ ./...
auto BufWritePre *.go Fmt
"gocode
for path in split($GOPATH, ':')
exe "set runtimepath+=" . globpath(path, "src/github.com/nsf/gocode/vim")
endfor
"golint
for path in split($GOPATH, ':')
exe "set runtimepath+=" . globpath(path, "src/github.com/golang/lint/misc/vim")
endfor
auto BufWritePost,FileWritePost *.go execute 'Lint' | cwindow
auto FileType go set errorformat=%*[0-9/]\ %*[0-9:]\ Failed\ parsing\ %f:\ %l:%c:\ %m,%f:%l:%c:\ %m,%f:%l:\ %m
filetype plugin indent on
syntax on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment