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

Updated plugins

This commit is contained in:
amix
2015-03-14 20:02:10 +00:00
parent d195ccb777
commit 2cb073a57d
73 changed files with 1098 additions and 525 deletions

View File

@ -81,13 +81,25 @@ function! go#cmd#Build(bang, ...)
let &makeprg = default_makeprg
endfunction
function! go#cmd#Test(...)
let command = "go test ."
if len(a:000)
let command = "go test " . expand(a:1)
function! go#cmd#Test(compile, ...)
let command = "go test "
" don't run the test, only compile it. Useful to capture and fix errors or
" to create a test binary.
if a:compile
let command .= "-c"
endif
if len(a:000)
let command .= expand(a:1)
endif
if a:compile
echon "vim-go: " | echohl Identifier | echon "compiling tests ..." | echohl None
else
echon "vim-go: " | echohl Identifier | echon "testing ..." | echohl None
endif
echon "vim-go: " | echohl Identifier | echon "testing ..." | echohl None
redraw
let out = go#tool#ExecuteInDir(command)
if v:shell_error
@ -103,7 +115,12 @@ function! go#cmd#Test(...)
else
call setqflist([])
cwindow
echon "vim-go: " | echohl Function | echon "[test] PASS" | echohl None
if a:compile
echon "vim-go: " | echohl Function | echon "[test] SUCCESS" | echohl None
else
echon "vim-go: " | echohl Function | echon "[test] PASS" | echohl None
endif
endif
endfunction

View File

@ -135,6 +135,11 @@ function! go#complete#Info()
endif
endfunction
function! s:trim_bracket(val)
let a:val.word = substitute(a:val.word, '[(){}\[\]]\+$', '', '')
return a:val
endfunction
fu! go#complete#Complete(findstart, base)
"findstart = 1 when we need to get the text length
if a:findstart == 1
@ -142,6 +147,10 @@ fu! go#complete#Complete(findstart, base)
return col('.') - g:gocomplete_completions[0] - 1
"findstart = 0 when we need to return the list of completions
else
let s = getline(".")[col('.') - 1]
if s =~ '[(){}\{\}]'
return map(copy(g:gocomplete_completions[1]), 's:trim_bracket(v:val)')
endif
return g:gocomplete_completions[1]
endif
endf

View File

@ -56,7 +56,7 @@ func! s:qflistSecond(output)
" We discard line2 and col2 for the first errorformat, because it's not
" useful and quickfix only has the ability to show one line and column
" number
let &errorformat = "%f:%l.%c-%.%#:\ %m,%f:%l:%c:\ %m"
let &errorformat = "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m"
" create the quickfix list and open it
cgetexpr split(a:output, "\n")
@ -189,6 +189,27 @@ endfunction
" Show all refs to entity denoted by selected identifier
function! go#oracle#Referrers(selected)
let out = s:RunOracle('referrers', a:selected)
" append line contents from Go source file for some messages:
" '...: referenced here'
" '...: reference to NAME'
let lines = split(out, "\n")
let extlines = []
for line in lines
if line =~# '\v: referenced here$|: reference to [^ :]*$'
let parts = split(line, ':')
" Note: we count -3 from end, to support additional comma in
" Windows-style C:\... paths
let filename = join(parts[0:-3], ':')
let linenum = parts[-2]
let extline = line . ': ' . readfile(filename, '', linenum)[linenum-1]
call add(extlines, extline)
else
call add(extlines, line)
endif
endfor
let out = join(extlines, "\n")
call s:qflistSecond(out)
endfunction

View File

@ -124,17 +124,21 @@ function! go#tool#BinPath(binpath)
let old_path = $PATH
let $PATH = $PATH . PathSep() .go_bin_path
if !executable(binpath)
if !executable(basename)
echo "vim-go: could not find '" . basename . "'. Run :GoInstallBinaries to fix it."
" restore back!
let $PATH = old_path
return ""
endif
" restore back!
if go_bin_path
let $PATH = old_path
let $PATH = old_path
let sep = '/'
if IsWin()
let sep = '\'
endif
return go_bin_path . '/' . basename
return go_bin_path . sep . basename
endfunction
" following two functions are from: https://github.com/mattn/gist-vim