Remove use of bindeval() as it is not suported in neovim
This commit is contained in:
parent
cb2e08b850
commit
dcdab63516
4 changed files with 62 additions and 49 deletions
|
|
@ -37,22 +37,11 @@ function! s:_OnClose( channel ) abort
|
|||
py3 _vimspector_session.OnServerExit( 0 )
|
||||
endfunction
|
||||
|
||||
function! s:_Send( msg ) abort
|
||||
call ch_sendraw( s:ch, a:msg )
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#channel#Timeout( id ) abort
|
||||
py3 << EOF
|
||||
_vimspector_session.OnRequestTimeout( vim.eval( 'a:id' ) )
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#channel#StartDebugSession( config ) abort
|
||||
|
||||
if exists( 's:ch' )
|
||||
echo 'Channel is already running'
|
||||
return v:none
|
||||
return v:false
|
||||
endif
|
||||
|
||||
let l:addr = 'localhost:' . a:config[ 'port' ]
|
||||
|
|
@ -70,10 +59,21 @@ function! vimspector#internal#channel#StartDebugSession( config ) abort
|
|||
if ch_status( s:ch ) !=# 'open'
|
||||
echom 'Unable to connect to debug adapter'
|
||||
redraw
|
||||
return v:none
|
||||
return v:false
|
||||
endif
|
||||
|
||||
return funcref( 's:_Send' )
|
||||
return v:true
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#channel#Send( msg ) abort
|
||||
call ch_sendraw( s:ch, a:msg )
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#channel#Timeout( id ) abort
|
||||
py3 << EOF
|
||||
_vimspector_session.OnRequestTimeout( vim.eval( 'a:id' ) )
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#channel#StopDebugSession() abort
|
||||
|
|
|
|||
|
|
@ -39,35 +39,11 @@ function! s:_OnClose( channel ) abort
|
|||
redraw
|
||||
endfunction
|
||||
|
||||
function! s:_Send( msg ) abort
|
||||
if ! exists( 's:job' )
|
||||
echom "Can't send message: Job was not initialised correctly"
|
||||
redraw
|
||||
return 0
|
||||
endif
|
||||
|
||||
if job_status( s:job ) !=# 'run'
|
||||
echom "Can't send message: Job is not running"
|
||||
redraw
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ch = job_getchannel( s:job )
|
||||
if ch ==# 'channel fail'
|
||||
echom 'Channel was closed unexpectedly!'
|
||||
redraw
|
||||
return 0
|
||||
endif
|
||||
|
||||
call ch_sendraw( ch, a:msg )
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#job#StartDebugSession( config ) abort
|
||||
if exists( 's:job' )
|
||||
echom 'Not starging: Job is already running'
|
||||
redraw
|
||||
return v:none
|
||||
return v:false
|
||||
endif
|
||||
|
||||
let s:job = job_start( a:config[ 'command' ],
|
||||
|
|
@ -91,10 +67,34 @@ function! vimspector#internal#job#StartDebugSession( config ) abort
|
|||
if job_status( s:job ) !=# 'run'
|
||||
echom 'Unable to start job, status is: ' . job_status( s:job )
|
||||
redraw
|
||||
return v:none
|
||||
return v:false
|
||||
endif
|
||||
|
||||
return funcref( 's:_Send' )
|
||||
return v:true
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#job#Send( msg ) abort
|
||||
if ! exists( 's:job' )
|
||||
echom "Can't send message: Job was not initialised correctly"
|
||||
redraw
|
||||
return 0
|
||||
endif
|
||||
|
||||
if job_status( s:job ) !=# 'run'
|
||||
echom "Can't send message: Job is not running"
|
||||
redraw
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ch = job_getchannel( s:job )
|
||||
if ch ==# 'channel fail'
|
||||
echom 'Channel was closed unexpectedly!'
|
||||
redraw
|
||||
return 0
|
||||
endif
|
||||
|
||||
call ch_sendraw( ch, a:msg )
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#job#StopDebugSession() abort
|
||||
|
|
|
|||
|
|
@ -492,19 +492,18 @@ class DebugSession( object ):
|
|||
self._adapter[ 'cwd' ] = os.getcwd()
|
||||
|
||||
vim.vars[ '_vimspector_adapter_spec' ] = self._adapter
|
||||
channel_send_func = vim.bindeval(
|
||||
"vimspector#internal#{}#StartDebugSession( "
|
||||
" g:_vimspector_adapter_spec "
|
||||
")".format( self._connection_type ) )
|
||||
|
||||
if channel_send_func is None:
|
||||
if not vim.eval( "vimspector#internal#{}#StartDebugSession( "
|
||||
" g:_vimspector_adapter_spec "
|
||||
")".format( self._connection_type ) ):
|
||||
self._logger.error( "Unable to start debug server" )
|
||||
else:
|
||||
self._connection = debug_adapter_connection.DebugAdapterConnection(
|
||||
self,
|
||||
channel_send_func )
|
||||
lambda msg: utils.Call(
|
||||
"vimspector#internal#{}#Send".format( self._connection_type ),
|
||||
msg ) )
|
||||
|
||||
self._logger.info( 'Debug Adapter Started' )
|
||||
self._logger.info( 'Debug Adapter Started' )
|
||||
|
||||
def _StopDebugAdapter( self, callback = None ):
|
||||
def handler( *args ):
|
||||
|
|
|
|||
|
|
@ -449,3 +449,17 @@ def ToUnicode( b ):
|
|||
if isinstance( b, bytes ):
|
||||
return b.decode( 'utf-8' )
|
||||
return b
|
||||
|
||||
|
||||
# Call a vimscript function with suplied arguments.
|
||||
def Call( vimscript_function, *args ):
|
||||
call = vimscript_function + '('
|
||||
for index, arg in enumerate( args ):
|
||||
arg_name = 'vimspector_internal_arg_{}'.format( index )
|
||||
vim.vars[ arg_name ] = arg
|
||||
call += 'g:' + arg_name
|
||||
if index:
|
||||
call += ','
|
||||
|
||||
call += ')'
|
||||
vim.eval( call )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue