Implement command line completion for watch/eval
This commit is contained in:
parent
1e8bd384b9
commit
355f0f0e0c
4 changed files with 53 additions and 3 deletions
|
|
@ -121,7 +121,10 @@ function! vimspector#CompleteOutput( ArgLead, CmdLine, CursorPos ) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
|
function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
|
||||||
return []
|
return join( py3eval( '_vimspector_session.GetCompletionsSync( '
|
||||||
|
\.' vim.eval( "a:CmdLine" ),'
|
||||||
|
\.' int( vim.eval( "a:CursorPos" ) ) )' ),
|
||||||
|
\ "\n" )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Boilerplate {{{
|
" Boilerplate {{{
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,13 @@ elseif s:mappings ==# 'HUMAN'
|
||||||
nmap <F12> <Plug>VimspectorStepOut
|
nmap <F12> <Plug>VimspectorStepOut
|
||||||
endif
|
endif
|
||||||
|
|
||||||
command! -bar -nargs=1 -complete=customlist,vimspector#CompleteExpr
|
command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
|
||||||
\ VimspectorWatch
|
\ VimspectorWatch
|
||||||
\ call vimspector#AddWatch( <f-args> )
|
\ call vimspector#AddWatch( <f-args> )
|
||||||
command! -bar -nargs=1 -complete=custom,vimspector#CompleteOutput
|
command! -bar -nargs=1 -complete=custom,vimspector#CompleteOutput
|
||||||
\ VimspectorShowOutput
|
\ VimspectorShowOutput
|
||||||
\ call vimspector#ShowOutput( <f-args> )
|
\ call vimspector#ShowOutput( <f-args> )
|
||||||
command! -bar -nargs=1 -complete=customlist,vimspector#CompleteExpr
|
command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
|
||||||
\ VimspectorEval
|
\ VimspectorEval
|
||||||
\ call vimspector#Evaluate( <f-args> )
|
\ call vimspector#Evaluate( <f-args> )
|
||||||
command! -bar
|
command! -bar
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,33 @@ class DebugAdapterConnection( object ):
|
||||||
if not self._SendMessage( msg ):
|
if not self._SendMessage( msg ):
|
||||||
self._AbortRequest( request, 'Unable to send message' )
|
self._AbortRequest( request, 'Unable to send message' )
|
||||||
|
|
||||||
|
|
||||||
|
def DoRequestSync( self, msg, timeout = 5000 ):
|
||||||
|
result = {}
|
||||||
|
|
||||||
|
def handler( msg ):
|
||||||
|
result[ 'response' ] = msg
|
||||||
|
|
||||||
|
def failure_handler( reason, msg ):
|
||||||
|
result[ 'response' ] = msg
|
||||||
|
result[ 'exception' ] = RuntimeError( reason )
|
||||||
|
|
||||||
|
self.DoRequest( handler, msg, failure_handler, timeout )
|
||||||
|
|
||||||
|
bug_catcher = 1000
|
||||||
|
while not result and bug_catcher >= 0:
|
||||||
|
vim.command( 'sleep 10m' )
|
||||||
|
bug_catcher -= 10
|
||||||
|
|
||||||
|
if result.get( 'exception' ) is not None:
|
||||||
|
raise result[ 'exception' ]
|
||||||
|
|
||||||
|
if result.get( 'response' ) is None:
|
||||||
|
raise RuntimeError( "No response" )
|
||||||
|
|
||||||
|
return result[ 'response' ]
|
||||||
|
|
||||||
|
|
||||||
def OnRequestTimeout( self, timer_id ):
|
def OnRequestTimeout( self, timer_id ):
|
||||||
request_id = None
|
request_id = None
|
||||||
for seq, request in self._outstanding_requests.items():
|
for seq, request in self._outstanding_requests.items():
|
||||||
|
|
|
||||||
|
|
@ -406,6 +406,26 @@ class DebugSession( object ):
|
||||||
def GetOutputBuffers( self ):
|
def GetOutputBuffers( self ):
|
||||||
return self._outputView.GetCategories()
|
return self._outputView.GetCategories()
|
||||||
|
|
||||||
|
def GetCompletionsSync( self, text_line, column_in_bytes ):
|
||||||
|
if not self._server_capabilities.get( 'supportsCompletionsRequest' ):
|
||||||
|
return []
|
||||||
|
|
||||||
|
response = self._connection.DoRequestSync( {
|
||||||
|
'command': 'completions',
|
||||||
|
'arguments': {
|
||||||
|
'frameId': self._stackTraceView.GetCurrentFrame()[ 'id' ],
|
||||||
|
# TODO: encoding ? bytes/codepoints
|
||||||
|
'text': text_line,
|
||||||
|
'column': column_in_bytes
|
||||||
|
}
|
||||||
|
} )
|
||||||
|
# TODO:
|
||||||
|
# - start / length
|
||||||
|
# - sortText
|
||||||
|
return [ i.get( 'text' ) or i[ 'label' ]
|
||||||
|
for i in response[ 'body' ][ 'targets' ] ]
|
||||||
|
|
||||||
|
|
||||||
def _SetUpUI( self ):
|
def _SetUpUI( self ):
|
||||||
vim.command( 'tabnew' )
|
vim.command( 'tabnew' )
|
||||||
self._uiTab = vim.current.tabpage
|
self._uiTab = vim.current.tabpage
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue