Updated plugins

This commit is contained in:
Amir Salihefendic
2019-11-16 16:28:42 +01:00
parent 96e10ed101
commit 72bdaba47e
204 changed files with 5936 additions and 1666 deletions

View File

@@ -23,7 +23,7 @@ if !exists('s:start_args')
let s:start_args = []
endif
function! s:groutineID() abort
function! s:goroutineID() abort
return s:state['currentThread'].goroutineID
endfunction
@@ -82,7 +82,7 @@ endfunction
function! s:call_jsonrpc(method, ...) abort
if go#util#HasDebug('debugger-commands')
echom 'sending to dlv ' . a:method
call go#util#EchoInfo('sending to dlv ' . a:method)
endif
let l:args = a:000
@@ -160,7 +160,7 @@ endfunction
" Populate the stacktrace window.
function! s:show_stacktrace(res) abort
if !has_key(a:res, 'result')
if type(a:res) isnot type({}) || !has_key(a:res, 'result') || empty(a:res.result)
return
endif
@@ -279,6 +279,7 @@ function! go#debug#Stop() abort
silent! exe bufwinnr(bufnr('__GODEBUG_STACKTRACE__')) 'wincmd c'
silent! exe bufwinnr(bufnr('__GODEBUG_VARIABLES__')) 'wincmd c'
silent! exe bufwinnr(bufnr('__GODEBUG_OUTPUT__')) 'wincmd c'
silent! exe bufwinnr(bufnr('__GODEBUG_GOROUTINES__')) 'wincmd c'
if has('balloon_eval')
let &ballooneval=s:ballooneval
@@ -325,10 +326,10 @@ endfunction
function! s:expand_var() abort
" Get name from struct line.
let name = matchstr(getline('.'), '^[^:]\+\ze: [a-zA-Z0-9\.·]\+{\.\.\.}$')
let name = matchstr(getline('.'), '^[^:]\+\ze: \*\?[a-zA-Z0-9-_/\.]\+\({\.\.\.}\)\?$')
" Anonymous struct
if name == ''
let name = matchstr(getline('.'), '^[^:]\+\ze: struct {.\{-}}$')
let name = matchstr(getline('.'), '^[^:]\+\ze: \*\?struct {.\{-}}$')
endif
if name != ''
@@ -418,23 +419,6 @@ function! s:start_cb() abort
endif
let debugwindows = go#config#DebugWindows()
if has_key(debugwindows, "stack") && debugwindows['stack'] != ''
exe 'silent ' . debugwindows['stack']
silent file `='__GODEBUG_STACKTRACE__'`
setlocal buftype=nofile bufhidden=wipe nomodified nobuflisted noswapfile nowrap nonumber nocursorline
setlocal filetype=godebugstacktrace
nmap <buffer> <cr> :<c-u>call <SID>goto_file()<cr>
nmap <buffer> q <Plug>(go-debug-stop)
endif
if has_key(debugwindows, "out") && debugwindows['out'] != ''
exe 'silent ' . debugwindows['out']
silent file `='__GODEBUG_OUTPUT__'`
setlocal buftype=nofile bufhidden=wipe nomodified nobuflisted noswapfile nowrap nonumber nocursorline
setlocal filetype=godebugoutput
nmap <buffer> q <Plug>(go-debug-stop)
endif
if has_key(debugwindows, "vars") && debugwindows['vars'] != ''
exe 'silent ' . debugwindows['vars']
silent file `='__GODEBUG_VARIABLES__'`
@@ -445,6 +429,33 @@ function! s:start_cb() abort
nmap <buffer> q <Plug>(go-debug-stop)
endif
if has_key(debugwindows, "stack") && debugwindows['stack'] != ''
exe 'silent ' . debugwindows['stack']
silent file `='__GODEBUG_STACKTRACE__'`
setlocal buftype=nofile bufhidden=wipe nomodified nobuflisted noswapfile nowrap nonumber nocursorline
setlocal filetype=godebugstacktrace
nmap <buffer> <cr> :<c-u>call <SID>goto_file()<cr>
nmap <buffer> q <Plug>(go-debug-stop)
endif
if has_key(debugwindows, "goroutines") && debugwindows['goroutines'] != ''
exe 'silent ' . debugwindows['goroutines']
silent file `='__GODEBUG_GOROUTINES__'`
setlocal buftype=nofile bufhidden=wipe nomodified nobuflisted noswapfile nowrap nonumber nocursorline
setlocal filetype=godebugvariables
call append(0, ["# Goroutines"])
nmap <buffer> <silent> <cr> :<c-u>call go#debug#Goroutine()<cr>
endif
if has_key(debugwindows, "out") && debugwindows['out'] != ''
exe 'silent ' . debugwindows['out']
silent file `='__GODEBUG_OUTPUT__'`
setlocal buftype=nofile bufhidden=wipe nomodified nobuflisted noswapfile nowrap nonumber nocursorline
setlocal filetype=godebugoutput
nmap <buffer> q <Plug>(go-debug-stop)
endif
call win_gotoid(l:winid)
silent! delcommand GoDebugStart
silent! delcommand GoDebugTest
command! -nargs=0 GoDebugContinue call go#debug#Stack('continue')
@@ -459,7 +470,7 @@ function! s:start_cb() abort
nnoremap <silent> <Plug>(go-debug-breakpoint) :<C-u>call go#debug#Breakpoint()<CR>
nnoremap <silent> <Plug>(go-debug-next) :<C-u>call go#debug#Stack('next')<CR>
nnoremap <silent> <Plug>(go-debug-step) :<C-u>call go#debug#Stack('step')<CR>
nnoremap <silent> <Plug>(go-debug-stepout) :<C-u>call go#debug#Stack('stepout')<CR>
nnoremap <silent> <Plug>(go-debug-stepout) :<C-u>call go#debug#Stack('stepOut')<CR>
nnoremap <silent> <Plug>(go-debug-continue) :<C-u>call go#debug#Stack('continue')<CR>
nnoremap <silent> <Plug>(go-debug-stop) :<C-u>call go#debug#Stop()<CR>
nnoremap <silent> <Plug>(go-debug-print) :<C-u>call go#debug#Print(expand('<cword>'))<CR>
@@ -472,8 +483,6 @@ function! s:start_cb() abort
set ballooneval
endif
call win_gotoid(l:winid)
augroup vim-go-debug
autocmd! * <buffer>
autocmd FileType go nmap <buffer> <F5> <Plug>(go-debug-continue)
@@ -487,7 +496,7 @@ endfunction
function! s:err_cb(ch, msg) abort
if get(s:state, 'ready', 0) != 0
call call('s:logger', ['ERR: ', a:ch, a:msg])
call s:logger('ERR: ', a:ch, a:msg)
return
endif
@@ -496,7 +505,7 @@ endfunction
function! s:out_cb(ch, msg) abort
if get(s:state, 'ready', 0) != 0
call call('s:logger', ['OUT: ', a:ch, a:msg])
call s:logger('OUT: ', a:ch, a:msg)
return
endif
@@ -771,6 +780,92 @@ function! go#debug#Print(arg) abort
endtry
endfunction
function! s:update_goroutines() abort
try
let l:res = s:call_jsonrpc('RPCServer.State')
let l:currentGoroutineID = 0
try
if type(l:res) is type({}) && has_key(l:res, 'result') && !empty(l:res['result'])
let l:currentGoroutineID = l:res["result"]["State"]["currentGoroutine"]["id"]
endif
catch
call go#util#EchoWarning("current goroutine not found...")
endtry
let l:res = s:call_jsonrpc('RPCServer.ListGoroutines')
call s:show_goroutines(l:currentGoroutineID, l:res)
catch
call go#util#EchoError(v:exception)
endtry
endfunction
function! s:show_goroutines(currentGoroutineID, res) abort
let l:goroutines_winid = bufwinid('__GODEBUG_GOROUTINES__')
if l:goroutines_winid == -1
return
endif
let l:winid = win_getid()
call win_gotoid(l:goroutines_winid)
try
setlocal modifiable
silent %delete _
let v = ['# Goroutines']
if type(a:res) isnot type({}) || !has_key(a:res, 'result') || empty(a:res['result'])
call setline(1, v)
return
endif
let l:goroutines = a:res["result"]["Goroutines"]
if len(l:goroutines) == 0
call go#util#EchoWarning("No Goroutines Running Now...")
call setline(1, v)
return
endif
for l:idx in range(len(l:goroutines))
let l:goroutine = l:goroutines[l:idx]
let l:goroutineType = ""
let l:loc = 0
if l:goroutine.startLoc.file != ""
let l:loc = l:goroutine.startLoc
let l:goroutineType = "Start"
endif
if l:goroutine.goStatementLoc.file != ""
let l:loc = l:goroutine.goStatementLoc
let l:goroutineType = "Go"
endif
if l:goroutine.currentLoc.file != ""
let l:loc = l:goroutine.currentLoc
let l:goroutineType = "Runtime"
endif
if l:goroutine.userCurrentLoc.file != ""
let l:loc=l:goroutine.userCurrentLoc
let l:goroutineType = "User"
endif
" The current goroutine can be changed by pressing enter on one of the
" lines listing a non-active goroutine. If the format of either of these
" lines is modified, then make sure that go#debug#Goroutine is also
" changed if needed.
if l:goroutine.id == a:currentGoroutineID
let l:g = printf("* Goroutine %s - %s: %s:%s %s (thread: %s)", l:goroutine.id, l:goroutineType, l:loc.file, l:loc.line, l:loc.function.name, l:goroutine.threadID)
else
let l:g = printf(" Goroutine %s - %s: %s:%s %s (thread: %s)", l:goroutine.id, l:goroutineType, l:loc.file, l:loc.line, l:loc.function.name, l:goroutine.threadID)
endif
let v += [l:g]
endfor
call setline(1, v)
finally
setlocal nomodifiable
call win_gotoid(l:winid)
endtry
endfunction
function! s:update_variables() abort
" FollowPointers requests pointers to be automatically dereferenced.
" MaxVariableRecurse is how far to recurse when evaluating nested types.
@@ -778,20 +873,27 @@ function! s:update_variables() abort
" MaxArrayValues is the maximum number of elements read from an array, a slice or a map.
" MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields.
let l:cfg = {
\ 'scope': {'GoroutineID': s:groutineID()},
\ 'scope': {'GoroutineID': s:goroutineID()},
\ 'cfg': {'MaxStringLen': 20, 'MaxArrayValues': 20}
\ }
try
let res = s:call_jsonrpc('RPCServer.ListLocalVars', l:cfg)
let s:state['localVars'] = res.result['Variables']
let s:state['localVars'] = {}
if type(l:res) is type({}) && has_key(l:res, 'result') && !empty(l:res.result)
let s:state['localVars'] = l:res.result['Variables']
endif
catch
call go#util#EchoError(v:exception)
endtry
try
let res = s:call_jsonrpc('RPCServer.ListFunctionArgs', l:cfg)
let s:state['functionArgs'] = res.result['Args']
let s:state['functionArgs'] = {}
if type(l:res) is type({}) && has_key(l:res, 'result') && !empty(l:res.result)
let s:state['functionArgs'] = res.result['Args']
endif
catch
call go#util#EchoError(v:exception)
endtry
@@ -816,7 +918,7 @@ endfunction
function! s:update_stacktrace() abort
try
let l:res = s:call_jsonrpc('RPCServer.Stacktrace', {'id': s:groutineID(), 'depth': 5})
let l:res = s:call_jsonrpc('RPCServer.Stacktrace', {'id': s:goroutineID(), 'depth': 5})
call s:show_stacktrace(l:res)
catch
call go#util#EchoError(v:exception)
@@ -826,10 +928,12 @@ endfunction
function! s:stack_cb(res) abort
let s:stack_name = ''
if empty(a:res) || !has_key(a:res, 'result')
if type(a:res) isnot type({}) || !has_key(a:res, 'result') || empty(a:res.result)
return
endif
call s:update_breakpoint(a:res)
call s:update_goroutines()
call s:update_stacktrace()
call s:update_variables()
endfunction
@@ -861,8 +965,20 @@ function! go#debug#Stack(name) abort
endif
let s:stack_name = l:name
try
let res = s:call_jsonrpc('RPCServer.Command', {'name': l:name})
call s:stack_cb(res)
let l:res = s:call_jsonrpc('RPCServer.Command', {'name': l:name})
if l:name is# 'next'
let l:res2 = l:res
let l:w = 0
while l:w < 1
if l:res2.result.State.NextInProgress == v:true
let l:res2 = s:call_jsonrpc('RPCServer.Command', {'name': 'continue'})
else
break
endif
endwhile
endif
call s:stack_cb(l:res)
catch
call go#util#EchoError(v:exception)
call s:clearState()
@@ -899,6 +1015,23 @@ function! s:isActive()
return len(s:state['message']) > 0
endfunction
" Change Goroutine
function! go#debug#Goroutine() abort
let l:goroutineID = substitute(getline('.'), '^ Goroutine \(.\{-1,\}\) - .*', '\1', 'g')
if l:goroutineID <= 0
return
endif
try
let l:res = s:call_jsonrpc('RPCServer.Command', {'Name': 'switchGoroutine', 'GoroutineID': str2nr(l:goroutineID)})
call s:stack_cb(l:res)
call go#util#EchoInfo("Switched goroutine to: " . l:goroutineID)
catch
call go#util#EchoError(v:exception)
endtry
endfunction
" Toggle breakpoint. Returns 0 on success and 1 on failure.
function! go#debug#Breakpoint(...) abort
let l:filename = fnamemodify(expand('%'), ':p:gs!\\!/!')