mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated vim plugins
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
## unplanned
|
||||
|
||||
## 1.12 - (March 29, 2017)
|
||||
|
||||
FEATURES:
|
||||
|
||||
* New `:GoAddTags` and `:GoRemoveTags` command based on the tool
|
||||
@ -20,6 +22,7 @@ if err != nil {
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
* vim-go works now even if GOPATH is not set (starting with Go 1.8) [gh-1248]
|
||||
* Lowercase `<Leader>` in mappings examples for consistent documentation across the README [gh-1192]
|
||||
* All of files should be written in utf-8 if the file will be passed to external command. [gh-1184]
|
||||
* `:GoAddTags` is now able to add options to existing tags with the syntax
|
||||
@ -27,6 +30,8 @@ IMPROVEMENTS:
|
||||
* Document 'noshowmode' requirement for echo_go_info [gh-1197]
|
||||
* Improve godoc view for vertical splits [gh-1195]
|
||||
* Set GOPATH for both possible go guru execution paths (sync and async) [gh-1193]
|
||||
* Improve docs for :GoDef usage [gh-1242]
|
||||
* Highlight trimming syntax for Go templates [gh-1235]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
@ -44,12 +49,13 @@ BUG FIXES:
|
||||
* Fix `:GoAddTags` not working if any field comment would contain `{}` [gh-1189]
|
||||
* Respect go_fmt_options when running goimports [gh-1211]
|
||||
* Set the filename in the location-list when there is an error with :GoFmt [gh-1199]
|
||||
* Fix `:GoInstall` to accept additional arguments if async mode was enabled [gh-1246]
|
||||
|
||||
BACKWARDS INCOMPATIBILITIES:
|
||||
|
||||
* The command `:GoGuruTags` is removed in favour of the new command
|
||||
`:GoBuildTags`. This command will be used now not just for `guru`, also for
|
||||
all new commands such as `guru` [gh-1232]
|
||||
all new commands such as `gorename` [gh-1232]
|
||||
* The setting `g:go_guru_tags` is removed in favour of the new setting
|
||||
`g:go_build_tags` [gh-1232]
|
||||
|
||||
|
@ -177,9 +177,6 @@ function! go#cmd#Install(bang, ...) abort
|
||||
" expand all wildcards(i.e: '%' to the current file name)
|
||||
let goargs = map(copy(a:000), "expand(v:val)")
|
||||
|
||||
" escape all shell arguments before we pass it to make
|
||||
let goargs = go#util#Shelllist(goargs, 1)
|
||||
|
||||
if get(g:, 'go_echo_command_info', 1)
|
||||
call go#util#EchoProgress("installing dispatched ...")
|
||||
endif
|
||||
@ -221,7 +218,7 @@ function! go#cmd#Install(bang, ...) abort
|
||||
if !empty(errors) && !a:bang
|
||||
call go#list#JumpToFirst(l:listtype)
|
||||
else
|
||||
call go#util#EchoSuccess("installed to ". $GOPATH)
|
||||
call go#util#EchoSuccess("installed to ". go#path#Detect())
|
||||
endif
|
||||
|
||||
let $GOPATH = old_gopath
|
||||
@ -407,7 +404,6 @@ function! go#cmd#Generate(bang, ...) abort
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
|
||||
" ---------------------
|
||||
" | Vim job callbacks |
|
||||
" ---------------------
|
||||
|
@ -136,6 +136,10 @@ endfunction
|
||||
" formated.
|
||||
function! go#fmt#run(bin_name, source, target)
|
||||
let cmd = s:fmt_cmd(a:bin_name, a:source, a:target)
|
||||
if empty(cmd)
|
||||
return
|
||||
endif
|
||||
|
||||
if cmd[0] == "goimports"
|
||||
" change GOPATH too, so goimports can pick up the correct library
|
||||
let old_gopath = $GOPATH
|
||||
@ -162,7 +166,7 @@ function! s:fmt_cmd(bin_name, source, target)
|
||||
" if not the user get's a warning via go#path#CheckBinPath()
|
||||
let bin_path = go#path#CheckBinPath(a:bin_name)
|
||||
if empty(bin_path)
|
||||
return
|
||||
return []
|
||||
endif
|
||||
|
||||
" start constructing the command
|
||||
@ -176,7 +180,7 @@ function! s:fmt_cmd(bin_name, source, target)
|
||||
if !exists('b:goimports_vendor_compatible')
|
||||
let out = go#util#System(bin_path . " --help")
|
||||
if out !~ "-srcdir"
|
||||
call go#util#EchoWarning(printf("vim-go: goimports (%s) does not support srcdir. Update with: :GoUpdateBinaries", bin_path))
|
||||
call go#util#EchoWarning(printf("vim-go: goimports (%s) does not support srcdir. Update with: :GoUpdateBinaries", , bin_path))
|
||||
else
|
||||
let b:goimports_vendor_compatible = 1
|
||||
endif
|
||||
|
@ -9,35 +9,41 @@ let s:initial_go_path = ""
|
||||
" GOPATH with it. If two double quotes are passed (the empty string in go),
|
||||
" it'll clear the GOPATH and will restore to the initial GOPATH.
|
||||
function! go#path#GoPath(...) abort
|
||||
" we have an argument, replace GOPATH
|
||||
if len(a:000)
|
||||
" clears the current manually set GOPATH and restores it to the
|
||||
" initial GOPATH, which was set when Vim was started.
|
||||
if len(a:000) == 1 && a:1 == '""'
|
||||
if !empty(s:initial_go_path)
|
||||
let $GOPATH = s:initial_go_path
|
||||
let s:initial_go_path = ""
|
||||
endif
|
||||
|
||||
echon "vim-go: " | echohl Function | echon "GOPATH restored to ". $GOPATH | echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
echon "vim-go: " | echohl Function | echon "GOPATH changed to ". a:1 | echohl None
|
||||
let s:initial_go_path = $GOPATH
|
||||
let $GOPATH = a:1
|
||||
" no argument, show GOPATH
|
||||
if len(a:000) == 0
|
||||
echo go#path#Detect()
|
||||
return
|
||||
endif
|
||||
|
||||
echo go#path#Detect()
|
||||
" we have an argument, replace GOPATH
|
||||
" clears the current manually set GOPATH and restores it to the
|
||||
" initial GOPATH, which was set when Vim was started.
|
||||
if len(a:000) == 1 && a:1 == '""'
|
||||
if !empty(s:initial_go_path)
|
||||
let $GOPATH = s:initial_go_path
|
||||
let s:initial_go_path = ""
|
||||
endif
|
||||
|
||||
echon "vim-go: " | echohl Function | echon "GOPATH restored to ". $GOPATH | echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
echon "vim-go: " | echohl Function | echon "GOPATH changed to ". a:1 | echohl None
|
||||
let s:initial_go_path = $GOPATH
|
||||
let $GOPATH = a:1
|
||||
endfunction
|
||||
|
||||
" Default returns the default GOPATH. If there is a single GOPATH it returns
|
||||
" it. For multiple GOPATHS separated with a the OS specific separator, only
|
||||
" the first one is returned
|
||||
" the first one is returned. If GOPATH is not set, it uses the default GOPATH
|
||||
" set starting with GO 1.8. This GOPATH can be retrieved via 'go env GOPATH'
|
||||
function! go#path#Default() abort
|
||||
let go_paths = split($GOPATH, go#util#PathListSep())
|
||||
if $GOPATH == ""
|
||||
" use default GOPATH via go env
|
||||
return go#util#gopath()
|
||||
endif
|
||||
|
||||
let go_paths = split($GOPATH, go#util#PathListSep())
|
||||
if len(go_paths) == 1
|
||||
return $GOPATH
|
||||
endif
|
||||
@ -48,7 +54,7 @@ endfunction
|
||||
" HasPath checks whether the given path exists in GOPATH environment variable
|
||||
" or not
|
||||
function! go#path#HasPath(path) abort
|
||||
let go_paths = split($GOPATH, go#util#PathListSep())
|
||||
let go_paths = split(go#path#Default(), go#util#PathListSep())
|
||||
let last_char = strlen(a:path) - 1
|
||||
|
||||
" check cases of '/foo/bar/' and '/foo/bar'
|
||||
@ -70,7 +76,7 @@ endfunction
|
||||
" over the current GOPATH. It also detects diretories whose are outside
|
||||
" GOPATH.
|
||||
function! go#path#Detect() abort
|
||||
let gopath = $GOPATH
|
||||
let gopath = go#path#Default()
|
||||
|
||||
" don't lookup for godeps if autodetect is disabled.
|
||||
if !get(g:, "go_autodetect_gopath", 1)
|
||||
@ -122,57 +128,58 @@ function! go#path#BinPath() abort
|
||||
let bin_path = ""
|
||||
|
||||
" check if our global custom path is set, if not check if $GOBIN is set so
|
||||
" we can use it, otherwise use $GOPATH + '/bin'
|
||||
" we can use it, otherwise use default GOPATH
|
||||
if exists("g:go_bin_path")
|
||||
let bin_path = g:go_bin_path
|
||||
elseif $GOBIN != ""
|
||||
let bin_path = $GOBIN
|
||||
elseif $GOPATH != ""
|
||||
let bin_path = expand(go#path#Default() . "/bin/")
|
||||
else
|
||||
" could not find anything
|
||||
endif
|
||||
else
|
||||
" GOPATH (user set or default GO)
|
||||
let bin_path = expand(go#path#Default() . "/bin/")
|
||||
endif
|
||||
|
||||
return bin_path
|
||||
return bin_path
|
||||
endfunction
|
||||
|
||||
" CheckBinPath checks whether the given binary exists or not and returns the
|
||||
" path of the binary. It returns an empty string doesn't exists.
|
||||
function! go#path#CheckBinPath(binpath) abort
|
||||
" remove whitespaces if user applied something like 'goimports '
|
||||
let binpath = substitute(a:binpath, '^\s*\(.\{-}\)\s*$', '\1', '')
|
||||
" save off original path
|
||||
let old_path = $PATH
|
||||
" remove whitespaces if user applied something like 'goimports '
|
||||
let binpath = substitute(a:binpath, '^\s*\(.\{-}\)\s*$', '\1', '')
|
||||
" save off original path
|
||||
let old_path = $PATH
|
||||
|
||||
" check if we have an appropriate bin_path
|
||||
let go_bin_path = go#path#BinPath()
|
||||
if !empty(go_bin_path)
|
||||
" append our GOBIN and GOPATH paths and be sure they can be found there...
|
||||
" let us search in our GOBIN and GOPATH paths
|
||||
let $PATH = go_bin_path . go#util#PathListSep() . $PATH
|
||||
" check if we have an appropriate bin_path
|
||||
let go_bin_path = go#path#BinPath()
|
||||
if !empty(go_bin_path)
|
||||
" append our GOBIN and GOPATH paths and be sure they can be found there...
|
||||
" let us search in our GOBIN and GOPATH paths
|
||||
let $PATH = go_bin_path . go#util#PathListSep() . $PATH
|
||||
endif
|
||||
|
||||
" if it's in PATH just return it
|
||||
if executable(binpath)
|
||||
if exists('*exepath')
|
||||
let binpath = exepath(binpath)
|
||||
endif
|
||||
|
||||
" if it's in PATH just return it
|
||||
if executable(binpath)
|
||||
if exists('*exepath')
|
||||
let binpath = exepath(binpath)
|
||||
endif
|
||||
let $PATH = old_path
|
||||
return binpath
|
||||
endif
|
||||
|
||||
" just get the basename
|
||||
let basename = fnamemodify(binpath, ":t")
|
||||
if !executable(basename)
|
||||
echom "vim-go: could not find '" . basename . "'. Run :GoInstallBinaries to fix it."
|
||||
" restore back!
|
||||
let $PATH = old_path
|
||||
return ""
|
||||
endif
|
||||
|
||||
let $PATH = old_path
|
||||
return binpath
|
||||
endif
|
||||
|
||||
return go_bin_path . go#util#PathSep() . basename
|
||||
" just get the basename
|
||||
let basename = fnamemodify(binpath, ":t")
|
||||
if !executable(basename)
|
||||
|
||||
call go#util#EchoError(printf("could not find '%s'. Run :GoInstallBinaries to fix it", basename))
|
||||
|
||||
" restore back!
|
||||
let $PATH = old_path
|
||||
return ""
|
||||
endif
|
||||
|
||||
let $PATH = old_path
|
||||
|
||||
return go_bin_path . go#util#PathSep() . basename
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
@ -217,15 +217,14 @@ COMMANDS *go-commands*
|
||||
If [!] is not given the first error is jumped to.
|
||||
|
||||
*:GoDef*
|
||||
:GoDef [identifier]
|
||||
:GoDef
|
||||
gd
|
||||
CTRL-]
|
||||
|
||||
Goto declaration/definition for the given [identifier]. If no argument is
|
||||
given, it will jump to the declaration under the cursor. By default the
|
||||
CTRL-] key and the mapping `gd` are enabled to invoke :GoDef for the
|
||||
Goto declaration/definition for the declaration under the cursor. By default
|
||||
the CTRL-] key and the mapping `gd` are enabled to invoke :GoDef for the
|
||||
identifier under the cursor. See |'g:go_def_mapping_enabled'| to disable
|
||||
them.
|
||||
them. No explicit arguments are supported.
|
||||
|
||||
vim-go also keeps a per-window location stack, roughly analogous to how
|
||||
Vim's internal |tags| functionality works. This is pushed to every time a
|
||||
|
@ -33,15 +33,15 @@ command! -nargs=? -complete=dir GoPath call go#path#GoPath(<f-args>)
|
||||
" target install directory. GoInstallBinaries doesn't install binaries if they
|
||||
" exist, to update current binaries pass 1 to the argument.
|
||||
function! s:GoInstallBinaries(updateBinaries)
|
||||
if $GOPATH == "" && go#util#gopath() == ""
|
||||
echohl Error
|
||||
echomsg "vim.go: $GOPATH is not set"
|
||||
echohl None
|
||||
let err = s:CheckBinaries()
|
||||
if err != 0
|
||||
return
|
||||
endif
|
||||
|
||||
let err = s:CheckBinaries()
|
||||
if err != 0
|
||||
if go#path#Default() == ""
|
||||
echohl Error
|
||||
echomsg "vim.go: $GOPATH is not set and 'go env GOPATH' returns empty"
|
||||
echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -74,8 +74,8 @@ hi def link goTplVariable Special
|
||||
|
||||
syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable,goTplIdentifier display
|
||||
syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable display
|
||||
syn region goTplComment start="{{/\*" end="\*/}}" display
|
||||
syn region goTplComment start="\[\[/\*" end="\*/\]\]" display
|
||||
syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display
|
||||
syn region goTplComment start="\[\[\(- \)\?/\*" end="\*/\( -\)\?\]\]" display
|
||||
|
||||
hi def link gotplAction PreProc
|
||||
hi def link goTplComment Comment
|
||||
|
Reference in New Issue
Block a user