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 )
|
py3 _vimspector_session.OnServerExit( 0 )
|
||||||
endfunction
|
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
|
function! vimspector#internal#channel#StartDebugSession( config ) abort
|
||||||
|
|
||||||
if exists( 's:ch' )
|
if exists( 's:ch' )
|
||||||
echo 'Channel is already running'
|
echo 'Channel is already running'
|
||||||
return v:none
|
return v:false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:addr = 'localhost:' . a:config[ 'port' ]
|
let l:addr = 'localhost:' . a:config[ 'port' ]
|
||||||
|
|
@ -70,10 +59,21 @@ function! vimspector#internal#channel#StartDebugSession( config ) abort
|
||||||
if ch_status( s:ch ) !=# 'open'
|
if ch_status( s:ch ) !=# 'open'
|
||||||
echom 'Unable to connect to debug adapter'
|
echom 'Unable to connect to debug adapter'
|
||||||
redraw
|
redraw
|
||||||
return v:none
|
return v:false
|
||||||
endif
|
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
|
endfunction
|
||||||
|
|
||||||
function! vimspector#internal#channel#StopDebugSession() abort
|
function! vimspector#internal#channel#StopDebugSession() abort
|
||||||
|
|
|
||||||
|
|
@ -39,35 +39,11 @@ function! s:_OnClose( channel ) abort
|
||||||
redraw
|
redraw
|
||||||
endfunction
|
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
|
function! vimspector#internal#job#StartDebugSession( config ) abort
|
||||||
if exists( 's:job' )
|
if exists( 's:job' )
|
||||||
echom 'Not starging: Job is already running'
|
echom 'Not starging: Job is already running'
|
||||||
redraw
|
redraw
|
||||||
return v:none
|
return v:false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:job = job_start( a:config[ 'command' ],
|
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'
|
if job_status( s:job ) !=# 'run'
|
||||||
echom 'Unable to start job, status is: ' . job_status( s:job )
|
echom 'Unable to start job, status is: ' . job_status( s:job )
|
||||||
redraw
|
redraw
|
||||||
return v:none
|
return v:false
|
||||||
endif
|
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
|
endfunction
|
||||||
|
|
||||||
function! vimspector#internal#job#StopDebugSession() abort
|
function! vimspector#internal#job#StopDebugSession() abort
|
||||||
|
|
|
||||||
|
|
@ -492,19 +492,18 @@ class DebugSession( object ):
|
||||||
self._adapter[ 'cwd' ] = os.getcwd()
|
self._adapter[ 'cwd' ] = os.getcwd()
|
||||||
|
|
||||||
vim.vars[ '_vimspector_adapter_spec' ] = self._adapter
|
vim.vars[ '_vimspector_adapter_spec' ] = self._adapter
|
||||||
channel_send_func = vim.bindeval(
|
if not vim.eval( "vimspector#internal#{}#StartDebugSession( "
|
||||||
"vimspector#internal#{}#StartDebugSession( "
|
" g:_vimspector_adapter_spec "
|
||||||
" g:_vimspector_adapter_spec "
|
")".format( self._connection_type ) ):
|
||||||
")".format( self._connection_type ) )
|
|
||||||
|
|
||||||
if channel_send_func is None:
|
|
||||||
self._logger.error( "Unable to start debug server" )
|
self._logger.error( "Unable to start debug server" )
|
||||||
else:
|
else:
|
||||||
self._connection = debug_adapter_connection.DebugAdapterConnection(
|
self._connection = debug_adapter_connection.DebugAdapterConnection(
|
||||||
self,
|
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 _StopDebugAdapter( self, callback = None ):
|
||||||
def handler( *args ):
|
def handler( *args ):
|
||||||
|
|
|
||||||
|
|
@ -449,3 +449,17 @@ def ToUnicode( b ):
|
||||||
if isinstance( b, bytes ):
|
if isinstance( b, bytes ):
|
||||||
return b.decode( 'utf-8' )
|
return b.decode( 'utf-8' )
|
||||||
return b
|
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