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:
Amir Salihefendic
2018-03-31 11:56:26 -03:00
parent 7c643a2d9c
commit 02572caa95
84 changed files with 4588 additions and 1749 deletions

View File

@ -78,7 +78,7 @@ function! s:guru_cmd(args) range abort
let scopes = go#util#StripTrailingSlash(scopes)
" create shell-safe entries of the list
if !go#util#has_job() | let scopes = go#util#Shelllist(scopes) | endif
if !has("nvim") && !go#util#has_job() | let scopes = go#util#Shelllist(scopes) | endif
" guru expect a comma-separated list of patterns, construct it
let l:scope = join(scopes, ",")
@ -129,7 +129,7 @@ function! s:sync_guru(args) abort
endif
if has_key(a:args, 'custom_parse')
call a:args.custom_parse(go#util#ShellError(), out)
call a:args.custom_parse(go#util#ShellError(), out, a:args.mode)
else
call s:parse_guru_output(go#util#ShellError(), out, a:args.mode)
endif
@ -137,6 +137,33 @@ function! s:sync_guru(args) abort
return out
endfunc
" use vim or neovim job api as appropriate
function! s:job_start(cmd, start_options) abort
if go#util#has_job()
return job_start(a:cmd, a:start_options)
endif
let opts = {'stdout_buffered': v:true, 'stderr_buffered': v:true}
function opts.on_stdout(job_id, data, event) closure
call a:start_options.callback(a:job_id, join(a:data, "\n"))
endfunction
function opts.on_stderr(job_id, data, event) closure
call a:start_options.callback(a:job_id, join(a:data, "\n"))
endfunction
function opts.on_exit(job_id, exit_code, event) closure
call a:start_options.exit_cb(a:job_id, a:exit_code)
call a:start_options.close_cb(a:job_id)
endfunction
" use a shell for input redirection if needed
let cmd = a:cmd
if has_key(a:start_options, 'in_io') && a:start_options.in_io ==# 'file' && !empty(a:start_options.in_name)
let cmd = ['/bin/sh', '-c', join(a:cmd, ' ') . ' <' . a:start_options.in_name]
endif
return jobstart(cmd, opts)
endfunction
" async_guru runs guru in async mode with the given arguments
function! s:async_guru(args) abort
let result = s:guru_cmd(a:args)
@ -145,8 +172,6 @@ function! s:async_guru(args) abort
return
endif
let status_dir = expand('%:p:h')
let statusline_type = printf("%s", a:args.mode)
if !has_key(a:args, 'disable_progress')
if a:args.needs_scope
@ -155,60 +180,64 @@ function! s:async_guru(args) abort
endif
endif
let messages = []
function! s:callback(chan, msg) closure
call add(messages, a:msg)
let state = {
\ 'status_dir': expand('%:p:h'),
\ 'statusline_type': printf("%s", a:args.mode),
\ 'mode': a:args.mode,
\ 'status': {},
\ 'exitval': 0,
\ 'closed': 0,
\ 'exited': 0,
\ 'messages': [],
\ 'parse' : get(a:args, 'custom_parse', funcref("s:parse_guru_output"))
\ }
function! s:callback(chan, msg) dict
call add(self.messages, a:msg)
endfunction
let status = {}
let exitval = 0
let closed = 0
let exited = 0
function! s:exit_cb(job, exitval) closure
let exited = 1
function! s:exit_cb(job, exitval) dict
let self.exited = 1
let status = {
\ 'desc': 'last status',
\ 'type': statusline_type,
\ 'type': self.statusline_type,
\ 'state': "finished",
\ }
if a:exitval
let exitval = a:exitval
let self.exitval = a:exitval
let status.state = "failed"
endif
call go#statusline#Update(status_dir, status)
call go#statusline#Update(self.status_dir, status)
if closed
call s:complete()
if self.closed
call self.complete()
endif
endfunction
function! s:close_cb(ch) closure
let closed = 1
function! s:close_cb(ch) dict
let self.closed = 1
if exited
call s:complete()
if self.exited
call self.complete()
endif
endfunction
function! s:complete() closure
let out = join(messages, "\n")
function state.complete() dict
let out = join(self.messages, "\n")
if has_key(a:args, 'custom_parse')
call a:args.custom_parse(exitval, out)
else
call s:parse_guru_output(exitval, out, a:args.mode)
endif
call self.parse(self.exitval, out, self.mode)
endfunction
" explicitly bind the callbacks to state so that self within them always
" refers to state. See :help Partial for more information.
let start_options = {
\ 'callback': funcref("s:callback"),
\ 'exit_cb': funcref("s:exit_cb"),
\ 'close_cb': funcref("s:close_cb"),
\ }
\ 'callback': function('s:callback', [], state),
\ 'exit_cb': function('s:exit_cb', [], state),
\ 'close_cb': function('s:close_cb', [], state)
\ }
if has_key(result, 'stdin_content')
let l:tmpname = tempname()
@ -217,18 +246,18 @@ function! s:async_guru(args) abort
let l:start_options.in_name = l:tmpname
endif
call go#statusline#Update(status_dir, {
call go#statusline#Update(state.status_dir, {
\ 'desc': "current status",
\ 'type': statusline_type,
\ 'type': state.statusline_type,
\ 'state': "analysing",
\})
return job_start(result.cmd, start_options)
return s:job_start(result.cmd, start_options)
endfunc
" run_guru runs the given guru argument
function! s:run_guru(args) abort
if go#util#has_job()
if has('nvim') || go#util#has_job()
let res = s:async_guru(a:args)
else
let res = s:sync_guru(a:args)
@ -289,7 +318,7 @@ function! go#guru#DescribeInfo() abort
return
endif
function! s:info(exit_val, output)
function! s:info(exit_val, output, mode)
if a:exit_val != 0
return
endif
@ -464,10 +493,6 @@ function! go#guru#Referrers(selected) abort
call s:run_guru(args)
endfunction
function! go#guru#SameIdsTimer() abort
call timer_start(200, function('go#guru#SameIds'), {'repeat': -1})
endfunction
function! go#guru#SameIds() abort
" we use matchaddpos() which was introduce with 7.4.330, be sure we have
" it: http://ftp.vim.org/vim/patches/7.4/7.4.330
@ -495,7 +520,7 @@ function! go#guru#SameIds() abort
call s:run_guru(args)
endfunction
function! s:same_ids_highlight(exit_val, output) abort
function! s:same_ids_highlight(exit_val, output, mode) abort
call go#guru#ClearSameIds() " run after calling guru to reduce flicker.
if a:output[0] !=# '{'