mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
update plugins
ran the plugin update script
This commit is contained in:
@ -33,7 +33,7 @@ function! go#auto#echo_go_info()
|
||||
endfunction
|
||||
|
||||
function! go#auto#auto_type_info()
|
||||
if !go#config#AutoTypeInfo() || !filereadable(expand('%:p'))
|
||||
if !go#config#AutoTypeInfo() || !isdirectory(expand('%:p:h'))
|
||||
return
|
||||
endif
|
||||
|
||||
@ -42,7 +42,7 @@ function! go#auto#auto_type_info()
|
||||
endfunction
|
||||
|
||||
function! go#auto#auto_sameids()
|
||||
if !go#config#AutoSameids() || !filereadable(expand('%:p'))
|
||||
if !go#config#AutoSameids() || !isdirectory(expand('%:p:h'))
|
||||
return
|
||||
endif
|
||||
|
||||
@ -51,7 +51,7 @@ function! go#auto#auto_sameids()
|
||||
endfunction
|
||||
|
||||
function! go#auto#fmt_autosave()
|
||||
if !go#config#FmtAutosave() || !filereadable(expand('%:p'))
|
||||
if !go#config#FmtAutosave() || !isdirectory(expand('%:p:h'))
|
||||
return
|
||||
endif
|
||||
|
||||
@ -60,7 +60,7 @@ function! go#auto#fmt_autosave()
|
||||
endfunction
|
||||
|
||||
function! go#auto#metalinter_autosave()
|
||||
if !go#config#MetalinterAutosave() || !filereadable(expand('%:p'))
|
||||
if !go#config#MetalinterAutosave() || !isdirectory(expand('%:p:h'))
|
||||
return
|
||||
endif
|
||||
|
||||
@ -69,7 +69,7 @@ function! go#auto#metalinter_autosave()
|
||||
endfunction
|
||||
|
||||
function! go#auto#modfmt_autosave()
|
||||
if !go#config#ModFmtAutosave() || !filereadable(expand('%:p'))
|
||||
if !go#config#ModFmtAutosave() || !isdirectory(expand('%:p:h'))
|
||||
return
|
||||
endif
|
||||
|
||||
@ -78,7 +78,7 @@ function! go#auto#modfmt_autosave()
|
||||
endfunction
|
||||
|
||||
function! go#auto#asmfmt_autosave()
|
||||
if !go#config#AsmfmtAutosave() || !filereadable(expand('%:p'))
|
||||
if !go#config#AsmfmtAutosave() || !isdirectory(expand('%:p:h'))
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -9,8 +9,8 @@ function! go#cmd#autowrite() abort
|
||||
for l:nr in range(0, bufnr('$'))
|
||||
if buflisted(l:nr) && getbufvar(l:nr, '&modified')
|
||||
" Sleep one second to make sure people see the message. Otherwise it is
|
||||
" often immediacy overwritten by the async messages (which also don't
|
||||
" invoke the "hit ENTER" prompt).
|
||||
" often immediately overwritten by the async messages (which also
|
||||
" doesn't invoke the "hit ENTER" prompt).
|
||||
call go#util#EchoWarning('[No write since last change]')
|
||||
sleep 1
|
||||
return
|
||||
|
@ -216,6 +216,7 @@ function! s:info_complete(echo, result) abort
|
||||
endfunction
|
||||
|
||||
function! s:trim_bracket(val) abort
|
||||
echom a:val
|
||||
let a:val.word = substitute(a:val.word, '[(){}\[\]]\+$', '', '')
|
||||
return a:val
|
||||
endfunction
|
||||
@ -240,7 +241,7 @@ function! go#complete#GocodeComplete(findstart, base) abort
|
||||
else
|
||||
let s = getline(".")[col('.') - 1]
|
||||
if s =~ '[(){}\{\}]'
|
||||
return map(copy(s:completions[1]), 's:trim_bracket(v:val)')
|
||||
return map(copy(s:completions), 's:trim_bracket(v:val)')
|
||||
endif
|
||||
return s:completions
|
||||
endif
|
||||
@ -257,7 +258,10 @@ function! go#complete#Complete(findstart, base) abort
|
||||
|
||||
"findstart = 1 when we need to get the start of the match
|
||||
if a:findstart == 1
|
||||
call go#lsp#Completion(expand('%:p'), line('.'), col('.'), funcref('s:handler', [l:state]))
|
||||
let l:completion = go#lsp#Completion(expand('%:p'), line('.'), col('.'), funcref('s:handler', [l:state]))
|
||||
if l:completion
|
||||
return -3
|
||||
endif
|
||||
|
||||
while !l:state.done
|
||||
sleep 10m
|
||||
|
@ -14,6 +14,10 @@ function! go#config#VersionWarning() abort
|
||||
return get(g:, 'go_version_warning', 1)
|
||||
endfunction
|
||||
|
||||
function! go#config#NullModuleWarning() abort
|
||||
return get(g:, 'go_null_module_warning', 1)
|
||||
endfunction
|
||||
|
||||
function! go#config#BuildTags() abort
|
||||
return get(g:, 'go_build_tags', '')
|
||||
endfunction
|
||||
|
@ -18,20 +18,30 @@ function! s:issuebody() abort
|
||||
for l in lines
|
||||
let body = add(body, l)
|
||||
|
||||
if l =~ '^\* Vim version'
|
||||
if l =~ '^<!-- :version'
|
||||
redir => out
|
||||
silent version
|
||||
redir END
|
||||
let body = extend(body, split(out, "\n")[0:2])
|
||||
elseif l =~ '^\* Go version'
|
||||
elseif l =~ '^<!-- go version -->'
|
||||
let [out, err] = go#util#Exec(['go', 'version'])
|
||||
let body = add(body, substitute(l:out, rtrimpat, '', ''))
|
||||
elseif l =~ '^\* Go environment'
|
||||
elseif l =~ '^<!-- go env -->'
|
||||
let [out, err] = go#util#Exec(['go', 'env'])
|
||||
let body = add(body, substitute(l:out, rtrimpat, '', ''))
|
||||
endif
|
||||
endfor
|
||||
|
||||
let body = add(body, "#### vim-go configuration:\n<details><summary>vim-go configuration</summary><br><pre>")
|
||||
|
||||
for k in keys(g:)
|
||||
if k =~ '^go_'
|
||||
let body = add(body, 'g:' . k . ' = ' . string(get(g:, k)))
|
||||
endif
|
||||
endfor
|
||||
|
||||
let body = add(body, '</pre></details>')
|
||||
|
||||
return join(body, "\n")
|
||||
endfunction
|
||||
|
||||
|
@ -101,11 +101,10 @@ function! go#lint#Gometa(bang, autosave, ...) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Golint calls 'golint' on the current directory. Any warnings are populated in
|
||||
" the location list
|
||||
" Golint calls 'golint'.
|
||||
function! go#lint#Golint(bang, ...) abort
|
||||
if a:0 == 0
|
||||
let [l:out, l:err] = go#util#Exec([go#config#GolintBin(), go#package#ImportPath()])
|
||||
let [l:out, l:err] = go#util#ExecInDir([go#config#GolintBin(), '.'])
|
||||
else
|
||||
let [l:out, l:err] = go#util#Exec([go#config#GolintBin()] + a:000)
|
||||
endif
|
||||
|
@ -7,7 +7,7 @@ scriptencoding utf-8
|
||||
let s:lspfactory = {}
|
||||
|
||||
function! s:lspfactory.get() dict abort
|
||||
if !has_key(self, 'current') || empty(self.current)
|
||||
if !has_key(self, 'current') || empty(self.current) || !has_key(self.current, 'job') || empty(self.current.job)
|
||||
let self.current = s:newlsp()
|
||||
endif
|
||||
|
||||
@ -22,9 +22,17 @@ endfunction
|
||||
|
||||
function! s:newlsp() abort
|
||||
if !go#util#has_job()
|
||||
let l:oldshortmess=&shortmess
|
||||
if has('nvim')
|
||||
set shortmess-=F
|
||||
endif
|
||||
" TODO(bc): start the server in the background using a shell that waits for the right output before returning.
|
||||
call go#util#EchoError('This feature requires either Vim 8.0.0087 or newer with +job or Neovim.')
|
||||
return
|
||||
call go#util#EchoWarning('Features that rely on gopls will not work without either Vim 8.0.0087 or newer with +job or Neovim')
|
||||
" Sleep one second to make sure people see the message. Otherwise it is
|
||||
" often immediately overwritten by an async message.
|
||||
sleep 1
|
||||
let &shortmess=l:oldshortmess
|
||||
return {'sendMessage': funcref('s:noop')}
|
||||
endif
|
||||
|
||||
" job is the job used to talk to the backing instance of gopls.
|
||||
@ -133,8 +141,17 @@ function! s:newlsp() abort
|
||||
return
|
||||
endif
|
||||
call l:handler.requestComplete(1)
|
||||
|
||||
let l:winidBeforeHandler = l:handler.winid
|
||||
call call(l:handler.handleResult, [l:response.result])
|
||||
call win_gotoid(l:winid)
|
||||
|
||||
" change the window back to the window that was active when
|
||||
" starting to handle the response _only_ if the handler didn't
|
||||
" update the winid, so that handlers can set the winid if needed
|
||||
" (e.g. :GoDef).
|
||||
if l:handler.winid == l:winidBeforeHandler
|
||||
call win_gotoid(l:winid)
|
||||
endif
|
||||
finally
|
||||
call remove(self.handlers, l:response.id)
|
||||
endtry
|
||||
@ -162,13 +179,32 @@ function! s:newlsp() abort
|
||||
let l:wd = go#util#ModuleRoot()
|
||||
if l:wd == -1
|
||||
call go#util#EchoError('could not determine appropriate working directory for gopls')
|
||||
return
|
||||
return -1
|
||||
endif
|
||||
|
||||
if l:wd == ''
|
||||
let l:wd = getcwd()
|
||||
endif
|
||||
|
||||
" do not attempt to send a message to gopls when using neither GOPATH
|
||||
" mode nor module mode.
|
||||
if go#package#FromPath(l:wd) == -2
|
||||
if go#config#NullModuleWarning() && (!has_key(self, 'warned') || !self.warned)
|
||||
let l:oldshortmess=&shortmess
|
||||
if has('nvim')
|
||||
set shortmess-=F
|
||||
endif
|
||||
call go#util#EchoWarning('Features that rely on gopls will not work correctly outside of GOPATH or a module.')
|
||||
let self.warned = 1
|
||||
" Sleep one second to make sure people see the message. Otherwise it is
|
||||
" often immediately overwritten by an async message.
|
||||
sleep 1
|
||||
let &shortmess=l:oldshortmess
|
||||
endif
|
||||
|
||||
return -1
|
||||
endif
|
||||
|
||||
let l:msg = self.newMessage(go#lsp#message#Initialize(l:wd))
|
||||
|
||||
let l:state = s:newHandlerState('')
|
||||
@ -351,7 +387,7 @@ function! go#lsp#Definition(fname, line, col, handler) abort
|
||||
let l:state = s:newHandlerState('definition')
|
||||
let l:state.handleResult = funcref('s:definitionHandler', [function(a:handler, [], l:state)], l:state)
|
||||
let l:msg = go#lsp#message#Definition(fnamemodify(a:fname, ':p'), a:line, a:col)
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! s:definitionHandler(next, msg) abort dict
|
||||
@ -373,7 +409,7 @@ function! go#lsp#TypeDef(fname, line, col, handler) abort
|
||||
let l:state = s:newHandlerState('type definition')
|
||||
let l:msg = go#lsp#message#TypeDefinition(fnamemodify(a:fname, ':p'), a:line, a:col)
|
||||
let l:state.handleResult = funcref('s:typeDefinitionHandler', [function(a:handler, [], l:state)], l:state)
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! s:typeDefinitionHandler(next, msg) abort dict
|
||||
@ -396,9 +432,13 @@ function! go#lsp#DidOpen(fname) abort
|
||||
let l:msg = go#lsp#message#DidOpen(fnamemodify(a:fname, ':p'), join(go#util#GetLines(), "\n") . "\n")
|
||||
let l:state = s:newHandlerState('')
|
||||
let l:state.handleResult = funcref('s:noop')
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
|
||||
" TODO(bc): setting a buffer level variable here assumes that a:fname is the
|
||||
" current buffer. Change to a:fname first before setting it and then change
|
||||
" back to active buffer.
|
||||
let b:go_lsp_did_open = 1
|
||||
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! go#lsp#DidChange(fname) abort
|
||||
@ -419,7 +459,7 @@ function! go#lsp#DidChange(fname) abort
|
||||
let l:msg = go#lsp#message#DidChange(fnamemodify(a:fname, ':p'), join(go#util#GetLines(), "\n") . "\n")
|
||||
let l:state = s:newHandlerState('')
|
||||
let l:state.handleResult = funcref('s:noop')
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! go#lsp#DidClose(fname) abort
|
||||
@ -435,9 +475,12 @@ function! go#lsp#DidClose(fname) abort
|
||||
let l:msg = go#lsp#message#DidClose(fnamemodify(a:fname, ':p'))
|
||||
let l:state = s:newHandlerState('')
|
||||
let l:state.handleResult = funcref('s:noop')
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
|
||||
" TODO(bc): setting a buffer level variable here assumes that a:fname is the
|
||||
" current buffer. Change to a:fname first before setting it and then change
|
||||
" back to active buffer.
|
||||
let b:go_lsp_did_open = 0
|
||||
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! go#lsp#Completion(fname, line, col, handler) abort
|
||||
@ -448,7 +491,7 @@ function! go#lsp#Completion(fname, line, col, handler) abort
|
||||
let l:state = s:newHandlerState('completion')
|
||||
let l:state.handleResult = funcref('s:completionHandler', [function(a:handler, [], l:state)], l:state)
|
||||
let l:state.error = funcref('s:completionErrorHandler', [function(a:handler, [], l:state)], l:state)
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! s:completionHandler(next, msg) abort dict
|
||||
@ -462,6 +505,9 @@ function! s:completionHandler(next, msg) abort dict
|
||||
let l:match = {'abbr': l:item.label, 'word': l:item.textEdit.newText, 'info': '', 'kind': go#lsp#completionitemkind#Vim(l:item.kind)}
|
||||
if has_key(l:item, 'detail')
|
||||
let l:match.info = l:item.detail
|
||||
if go#lsp#completionitemkind#IsFunction(l:item.kind) || go#lsp#completionitemkind#IsMethod(l:item.kind)
|
||||
let l:match.info = printf('func %s %s', l:item.label, l:item.detail)
|
||||
endif
|
||||
endif
|
||||
|
||||
if has_key(l:item, 'documentation')
|
||||
@ -475,7 +521,7 @@ function! s:completionHandler(next, msg) abort dict
|
||||
endfunction
|
||||
|
||||
function! s:completionErrorHandler(next, error) abort dict
|
||||
call call(a:next, [[]])
|
||||
call call(a:next, [-1, []])
|
||||
endfunction
|
||||
|
||||
function! go#lsp#Hover(fname, line, col, handler) abort
|
||||
@ -486,7 +532,7 @@ function! go#lsp#Hover(fname, line, col, handler) abort
|
||||
let l:state = s:newHandlerState('')
|
||||
let l:state.handleResult = funcref('s:hoverHandler', [function(a:handler, [], l:state)], l:state)
|
||||
let l:state.error = funcref('s:noop')
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! s:hoverHandler(next, msg) abort dict
|
||||
@ -515,13 +561,13 @@ function! go#lsp#Info(showstatus)
|
||||
let l:state = s:newHandlerState('')
|
||||
endif
|
||||
|
||||
let l:state.handleResult = funcref('s:infoDefinitionHandler', [function('s:info', []), a:showstatus], l:state)
|
||||
let l:state.handleResult = funcref('s:infoDefinitionHandler', [a:showstatus], l:state)
|
||||
let l:state.error = funcref('s:noop')
|
||||
let l:msg = go#lsp#message#Definition(l:fname, l:line, l:col)
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! s:infoDefinitionHandler(next, showstatus, msg) abort dict
|
||||
function! s:infoDefinitionHandler(showstatus, msg) abort dict
|
||||
" gopls returns a []Location; just take the first one.
|
||||
let l:msg = a:msg[0]
|
||||
|
||||
@ -540,11 +586,15 @@ function! s:infoDefinitionHandler(next, showstatus, msg) abort dict
|
||||
|
||||
let l:state.handleResult = funcref('s:hoverHandler', [function('s:info', [], l:state)], l:state)
|
||||
let l:state.error = funcref('s:noop')
|
||||
call l:lsp.sendMessage(l:msg, l:state)
|
||||
return l:lsp.sendMessage(l:msg, l:state)
|
||||
endfunction
|
||||
|
||||
function! s:info(content) abort dict
|
||||
let l:content = a:content[0]
|
||||
|
||||
" strip godoc summary
|
||||
let l:content = substitute(l:content, '^[^\n]\+\n', '', '')
|
||||
|
||||
" strip off the method set and fields of structs and interfaces.
|
||||
if l:content =~# '^type [^ ]\+ \(struct\|interface\)'
|
||||
let l:content = substitute(l:content, '{.*', '', '')
|
||||
|
@ -144,12 +144,19 @@ function! go#package#FromPath(arg) abort
|
||||
let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||
let l:dir = getcwd()
|
||||
|
||||
let l:path = a:arg
|
||||
let l:path = fnamemodify(a:arg, ':p')
|
||||
if !isdirectory(l:path)
|
||||
let l:path = fnamemodify(l:path, ':h')
|
||||
endif
|
||||
|
||||
execute l:cd fnameescape(l:path)
|
||||
if glob("*.go") == ""
|
||||
" There's no Go code in this directory. We might be in a module directory
|
||||
" which doesn't have any code at this level.
|
||||
if !empty(s:module())
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
let [l:out, l:err] = go#util#Exec(['go', 'list'])
|
||||
execute l:cd fnameescape(l:dir)
|
||||
if l:err != 0
|
||||
|
@ -66,9 +66,9 @@ endfunc
|
||||
func! Test_GoTestShowName() abort
|
||||
let expected = [
|
||||
\ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'TestHelloWorld'},
|
||||
\ {'lnum': 6, 'bufnr': 7, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'so long'},
|
||||
\ {'lnum': 6, 'bufnr': 8, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'so long'},
|
||||
\ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'TestHelloWorld/sub'},
|
||||
\ {'lnum': 9, 'bufnr': 7, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'thanks for all the fish'},
|
||||
\ {'lnum': 9, 'bufnr': 8, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'thanks for all the fish'},
|
||||
\ ]
|
||||
|
||||
let g:go_test_show_name=1
|
||||
@ -78,14 +78,14 @@ endfunc
|
||||
|
||||
func! Test_GoTestVet() abort
|
||||
let expected = [
|
||||
\ {'lnum': 6, 'bufnr': 10, 'col': 2, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'Errorf format %v reads arg #1, but call has 0 args'},
|
||||
\ {'lnum': 6, 'bufnr': 11, 'col': 2, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'Errorf format %v reads arg #1, but call has 0 args'},
|
||||
\ ]
|
||||
call s:test('veterror/veterror.go', expected)
|
||||
endfunc
|
||||
|
||||
func! Test_GoTestTestCompilerError() abort
|
||||
let expected = [
|
||||
\ {'lnum': 10, 'bufnr': 8, 'col': 16, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'cannot use r (type struct {}) as type io.Reader in argument to ioutil.ReadAll:'},
|
||||
\ {'lnum': 10, 'bufnr': 9, 'col': 16, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'cannot use r (type struct {}) as type io.Reader in argument to ioutil.ReadAll:'},
|
||||
\ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'struct {} does not implement io.Reader (missing Read method)'}
|
||||
\ ]
|
||||
|
||||
|
@ -557,7 +557,9 @@ function! go#util#SetEnv(name, value) abort
|
||||
let l:remove = 1
|
||||
endif
|
||||
|
||||
call execute('let $' . a:name . ' = "' . a:value . '"')
|
||||
" wrap the value in single quotes so that it will work on windows when there
|
||||
" are backslashes present in the value (e.g. $PATH).
|
||||
call execute('let $' . a:name . " = '" . a:value . "'")
|
||||
|
||||
if l:remove
|
||||
function! s:remove(name) abort
|
||||
|
Reference in New Issue
Block a user