Neovim support
This commit is contained in:
parent
05bbafd60c
commit
cd5ca37ce1
2 changed files with 66 additions and 55 deletions
|
|
@ -147,11 +147,10 @@ function! vimspector#internal#job#Reset() abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:_OnCommandExit( category, ch, code ) abort
|
function! s:_OnCommandExit( category, ch, code ) abort
|
||||||
py3 << EOF
|
py3 __import__( "vimspector",
|
||||||
from vimspector import utils as vimspector_utils
|
\ fromlist = [ "utils" ] ).utils.OnCommandWithLogComplete(
|
||||||
vimspector_utils.OnCommandWithLogComplete( vim.eval( 'a:category' ),
|
\ vim.eval( 'a:category' ),
|
||||||
int( vim.eval( 'a:code' ) ) )
|
\ int( vim.eval( 'a:code' ) ) )
|
||||||
EOF
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#internal#job#StartCommandWithLog( cmd, category ) abort
|
function! vimspector#internal#job#StartCommandWithLog( cmd, category ) abort
|
||||||
|
|
|
||||||
|
|
@ -116,58 +116,65 @@ function! s:_OnCommandEvent( category, id, data, event ) abort
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:data == ['']
|
if a:event ==# 'stdout' || a:event ==# 'stderr'
|
||||||
return
|
if a:data == ['']
|
||||||
endif
|
return
|
||||||
|
|
||||||
if !has_key( s:commands, a:category )
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !has_key( s:commands[ a:category ], a:id )
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:event ==# 'stdout'
|
|
||||||
let buffer = s:commands[ a:category ][ a:id ].stdout
|
|
||||||
elseif a:event ==# 'stderr'
|
|
||||||
let buffer = s:commands[ a:category ][ a:id ].stderr
|
|
||||||
endif
|
|
||||||
|
|
||||||
try
|
|
||||||
call bufload( buffer )
|
|
||||||
catch /E325/
|
|
||||||
" Ignore E325/ATTENTION
|
|
||||||
endtry
|
|
||||||
|
|
||||||
|
|
||||||
let numlines = py3eval( "len( vim.buffers[ int( vim.eval( 'buffer' ) ) ] )" )
|
|
||||||
let last_line = getbufline( buffer, '$' )[ 0 ]
|
|
||||||
|
|
||||||
call s:MakeBufferWritable( buffer )
|
|
||||||
try
|
|
||||||
if numlines == 1 && last_line ==# ''
|
|
||||||
call setbufline( buffer, 1, a:data[ 0 ] )
|
|
||||||
else
|
|
||||||
call setbufline( buffer, '$', last_line . a:data[ 0 ] )
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call appendbufline( buffer, '$', a:data[ 1: ] )
|
if !has_key( s:commands, a:category )
|
||||||
finally
|
return
|
||||||
call s:MakeBufferReadOnly( buffer )
|
endif
|
||||||
call setbufvar( buffer, '&modified', 0 )
|
|
||||||
endtry
|
if !has_key( s:commands[ a:category ], a:id )
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if a:event ==# 'stdout'
|
||||||
|
let buffer = s:commands[ a:category ][ a:id ].stdout
|
||||||
|
elseif a:event ==# 'stderr'
|
||||||
|
let buffer = s:commands[ a:category ][ a:id ].stderr
|
||||||
|
endif
|
||||||
|
|
||||||
" if the buffer is visible, scroll it
|
|
||||||
let w = bufwinnr( buffer )
|
|
||||||
if w > 0
|
|
||||||
let cw = winnr()
|
|
||||||
try
|
try
|
||||||
execute w . 'wincmd w'
|
call bufload( buffer )
|
||||||
normal! Gz.
|
catch /E325/
|
||||||
finally
|
" Ignore E325/ATTENTION
|
||||||
execute cw . 'wincmd w'
|
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
|
||||||
|
let numlines = py3eval( "len( vim.buffers[ int( vim.eval( 'buffer' ) ) ] )" )
|
||||||
|
let last_line = getbufline( buffer, '$' )[ 0 ]
|
||||||
|
|
||||||
|
call s:MakeBufferWritable( buffer )
|
||||||
|
try
|
||||||
|
if numlines == 1 && last_line ==# ''
|
||||||
|
call setbufline( buffer, 1, a:data[ 0 ] )
|
||||||
|
else
|
||||||
|
call setbufline( buffer, '$', last_line . a:data[ 0 ] )
|
||||||
|
endif
|
||||||
|
|
||||||
|
call appendbufline( buffer, '$', a:data[ 1: ] )
|
||||||
|
finally
|
||||||
|
call s:MakeBufferReadOnly( buffer )
|
||||||
|
call setbufvar( buffer, '&modified', 0 )
|
||||||
|
endtry
|
||||||
|
|
||||||
|
" if the buffer is visible, scroll it
|
||||||
|
let w = bufwinnr( buffer )
|
||||||
|
if w > 0
|
||||||
|
let cw = winnr()
|
||||||
|
try
|
||||||
|
execute w . 'wincmd w'
|
||||||
|
normal! Gz-
|
||||||
|
finally
|
||||||
|
execute cw . 'wincmd w'
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
elseif a:event ==# 'exit'
|
||||||
|
py3 __import__( "vimspector",
|
||||||
|
\ fromlist = [ "utils" ] ).utils.OnCommandWithLogComplete(
|
||||||
|
\ vim.eval( 'a:category' ),
|
||||||
|
\ int( vim.eval( 'a:data' ) ) )
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
@ -210,7 +217,9 @@ function! vimspector#internal#neojob#StartCommandWithLog( cmd, category ) abort
|
||||||
\ 'on_stdout': funcref( 's:_OnCommandEvent',
|
\ 'on_stdout': funcref( 's:_OnCommandEvent',
|
||||||
\ [ a:category ] ),
|
\ [ a:category ] ),
|
||||||
\ 'on_stderr': funcref( 's:_OnCommandEvent',
|
\ 'on_stderr': funcref( 's:_OnCommandEvent',
|
||||||
\ [ a:category ] )
|
\ [ a:category ] ),
|
||||||
|
\ 'on_exit': funcref( 's:_OnCommandEvent',
|
||||||
|
\ [ a:category ] ),
|
||||||
\ } )
|
\ } )
|
||||||
|
|
||||||
let s:commands[ a:category ][ id ] = {
|
let s:commands[ a:category ][ id ] = {
|
||||||
|
|
@ -227,8 +236,11 @@ function! vimspector#internal#neojob#CleanUpCommand( category ) abort
|
||||||
endif
|
endif
|
||||||
|
|
||||||
for id in keys( s:commands[ a:category ] )
|
for id in keys( s:commands[ a:category ] )
|
||||||
call jobstop( str2nr( id ) )
|
let id = str2nr( id )
|
||||||
call jobwait( [ str2nr( id ) ] )
|
if jobwait( [ id ], 0 )[ 0 ] == -1
|
||||||
|
call jobstop( id )
|
||||||
|
endif
|
||||||
|
call jobwait( [ id ], -1 )
|
||||||
endfor
|
endfor
|
||||||
unlet! s:commands[ a:category ]
|
unlet! s:commands[ a:category ]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue