1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
amix
2015-02-04 10:43:54 +00:00
parent e7a01094b6
commit a4b4587019
71 changed files with 2076 additions and 1112 deletions

View File

@ -189,6 +189,22 @@ let g:go_highlight_structs = 1
## Troubleshooting
### Command not found
If trying to use `:GoDef`, `:GoInfo` and get a `command not found`, check that you have the binaries installed by using: `:GoInstallBinaries`
Before opening vim, check your current `$PATH`:
echo $PATH
after opening vim, run `:echo $PATH`, the output must be your current `$PATH` + `$PATH/bin` (the location where `:GoInstallBinaries` installed the binaries
If problem persists and you are using maybe 'csh' or other shell, try adding this to your .vimrc:
set shell=/bin/sh
### I'm using Fish shell but have some problems using Vim-go
First environment variables in Fish are applied differently, it should be like:
@ -202,13 +218,12 @@ too). To overcome this problem change the default shell by adding the following
into your .vimrc (on the top of the file):
if $SHELL =~ 'fish'
set shell='/bin/bash'
set shell='/bin/sh'
endif
or
set shell='/bin/bash'
set shell='/bin/sh'
## Why another plugin?
@ -221,6 +236,12 @@ months under heavy go development environment.
Give it a try. I hope you like it. Feel free to contribute to the project.
## Donations
Vim-go is an open source project and I'm working on it on my free times. I'm spending a lot of time and thoughts to make it stable, fixing bugs, adding new features, etc... If you like vim-go and find it helpful, you might give me a gift from some of the books (kindle) I have in my wish list:
[Amazon.com Fatih's Wish List](http://amzn.com/w/3RUTKZC0U30P6). Thanks!
## Credits
* Go Authors for official vim plugins

View File

@ -19,7 +19,12 @@ fu! s:gocodeCurrentBuffer()
return file
endf
let s:vim_system = get(g:, 'gocomplete#system_function', 'system')
if go#vimproc#has_vimproc()
let s:vim_system = get(g:, 'gocomplete#system_function', 'vimproc#system2')
else
let s:vim_system = get(g:, 'gocomplete#system_function', 'system')
endif
fu! s:system(str, ...)
return call(s:vim_system, [a:str] + a:000)

View File

@ -5,6 +5,10 @@ endif
function! go#errcheck#Run(...) abort
if a:0 == 0
let package = go#package#ImportPath(expand('%:p:h'))
if package == -1
echohl Error | echomsg "vim-go: package is not inside GOPATH src" | echohl None
return
endif
else
let package = a:1
end
@ -14,6 +18,7 @@ function! go#errcheck#Run(...) abort
return
endif
echon "vim-go: " | echohl Identifier | echon "errcheck analysing ..." | echohl None
let out = system(bin_path . ' ' . package)
if v:shell_error
let errors = []
@ -28,15 +33,21 @@ function! go#errcheck#Run(...) abort
\"text": tokens[4]})
endif
endfor
if empty(errors)
% | " Couldn't detect error format, output errors
echohl Error | echomsg "GoErrCheck returned error" | echohl None
echo out
endif
if !empty(errors)
redraw | echo
call setqflist(errors, 'r')
endif
echohl Error | echomsg "GoErrCheck returned error" | echohl None
else
call setqflist([])
endif
cwindow
endfunction
" vim:ts=4:sw=4:et

View File

@ -74,8 +74,15 @@ function! go#fmt#Format(withGoimport)
" get the command first so we can test it
let fmt_command = g:go_fmt_command
if a:withGoimport == 1
let fmt_command = g:go_goimports_bin
endif
" if it's something else than gofmt, we need to check the existing of that
" binary. For example if it's goimports, let us check if it's installed,
" if not the user get's a warning via go#tool#BinPath()
if fmt_command != "gofmt"
" check if the user has installed goimports
let bin_path = go#tool#BinPath(g:go_goimports_bin)
let bin_path = go#tool#BinPath(fmt_command)
if empty(bin_path)
return
endif

View File

@ -32,7 +32,8 @@ function! go#tool#Imports()
endif
for package_path in split(out, '\n')
let package_name = fnamemodify(package_path, ":t:r")
let cmd = "go list -f {{.Name}} " . package_path
let package_name = substitute(go#tool#ExecuteInDir(cmd), '\n$', '', '')
let imports[package_name] = package_path
endfor

View File

@ -0,0 +1,21 @@
"Check if has vimproc
function! go#vimproc#has_vimproc()
if !exists('g:go#use_vimproc')
if IsWin()
try
call vimproc#version()
let exists_vimproc = 1
catch
let exists_vimproc = 0
endtry
else
let exists_vimproc = 0
endif
let g:go#use_vimproc = exists_vimproc
endif
return g:go#use_vimproc
endfunction
" vim:ts=4:sw=4:et

View File

@ -558,6 +558,12 @@ Highlights method names. By default it's disabled. >
Highlights struct names. By default it's disabled. >
let g:go_highlight_structs = 0
<
*'g:go_highlight_build_constraints'*
Highlights build constraints. By default it's disabled. >
let g:go_highlight_build_constraints = 0
<
*'g:go_textobj_enabled'*

View File

@ -10,8 +10,9 @@ endsnippet
# anonymous function
snippet anon "fn := func() { ... }"
${1:fn} := func() {
${0}
${2:${VISUAL}}
}
${0}
endsnippet
# append
@ -192,7 +193,7 @@ endsnippet
# Fmt Printf debug
snippet ff "fmt.Printf(...)"
fmt.Printf("${1} = %+v\n", $1)
fmt.Printf("${1:${VISUAL}} = %+v\n", $1)
endsnippet
# Fmt Println debug
@ -294,8 +295,9 @@ endsnippet
# goroutine anonymous function
snippet gof "go func() { ... }()"
go func() {
${1}
${1:${VISUAL}}
}()
${0}
endsnippet
# test function

View File

@ -9,7 +9,7 @@ let g:go_loaded_install = 1
let s:packages = [
\ "github.com/nsf/gocode",
\ "golang.org/x/tools/cmd/goimports",
\ "code.google.com/p/rog-go/exp/cmd/godef",
\ "github.com/rogpeppe/godef",
\ "golang.org/x/tools/cmd/oracle",
\ "golang.org/x/tools/cmd/gorename",
\ "github.com/golang/lint/golint",
@ -166,11 +166,6 @@ function! s:CheckBinaries()
echohl Error | echomsg "vim-go: git executable not found." | echohl None
return -1
endif
if !executable('hg')
echohl Error | echomsg "vim.go: hg (mercurial) executable not found." | echohl None
return -1
endif
endfunction
" Autocommands

View File

@ -67,6 +67,10 @@ if !exists("g:go_highlight_structs")
let g:go_highlight_structs = 0
endif
if !exists("g:go_highlight_build_constraints")
let g:go_highlight_build_constraints = 0
endif
syn case match
syn keyword goDirective package import
@ -270,6 +274,21 @@ endif
hi def link goStruct Function
hi def link goStructDef Function
" Build Constraints
if g:go_highlight_build_constraints != 0
syn keyword goBuildOs contained ignore cgo android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows
syn keyword goBuildArch contained 386 amd64 amd64p32 arm
syn match goBuildDirective display contained "+build"
syn region goBuildComment start="//\s*+build" end="$" contains=goBuildDirective,goBuildOs,goBuildArch
syn region goBuildComment start="/\*\s*+build" end="\*/" contains=goBuildDirective,goBuildOs,goBuildArch
endif
hi def link goBuildComment Comment
hi def link goBuildOs Type
hi def link goBuildArch Type
hi def link goBuildDirective PreProc
" Search backwards for a global declaration to start processing the syntax.
"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/