Support completion for console and watches.
Add omnifunc for prompt buffers
This synchronous completion can be used with any completion system
including built-in CTRL-X CTRL-O.
The filetype of the prompt buffers is set to VimspectorPrompt so that it
can be identified by completion systems. For example, this works well
with YCM:
let g:ycm_semantic_triggers = {
\ 'VimspectorPrompt': [ '.', '->', ':', '<' ]
\ }
This commit is contained in:
parent
e81be848a1
commit
733843a6d4
5 changed files with 113 additions and 8 deletions
|
|
@ -554,8 +554,7 @@ class DebugSession( object ):
|
|||
# TODO:
|
||||
# - start / length
|
||||
# - sortText
|
||||
return [ i.get( 'text' ) or i[ 'label' ]
|
||||
for i in response[ 'body' ][ 'targets' ] ]
|
||||
return response[ 'body' ][ 'targets' ]
|
||||
|
||||
|
||||
def _SetUpUI( self ):
|
||||
|
|
|
|||
|
|
@ -192,7 +192,8 @@ class OutputView( object ):
|
|||
utils.SetUpPromptBuffer( tab_buffer.buf,
|
||||
name,
|
||||
'> ',
|
||||
'vimspector#EvaluateConsole' )
|
||||
'vimspector#EvaluateConsole',
|
||||
'vimspector#OmniFuncConsole' )
|
||||
else:
|
||||
utils.SetUpHiddenBuffer( tab_buffer.buf, name )
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ def SetUpHiddenBuffer( buf, name ):
|
|||
buf.name = name
|
||||
|
||||
|
||||
def SetUpPromptBuffer( buf, name, prompt, callback ):
|
||||
def SetUpPromptBuffer( buf, name, prompt, callback, omnifunc ):
|
||||
# This feature is _super_ new, so only enable when available
|
||||
if not Exists( '*prompt_setprompt' ):
|
||||
return SetUpHiddenBuffer( buf, name )
|
||||
|
|
@ -148,6 +148,7 @@ def SetUpPromptBuffer( buf, name, prompt, callback ):
|
|||
buf.options[ 'buflisted' ] = False
|
||||
buf.options[ 'bufhidden' ] = 'hide'
|
||||
buf.options[ 'textwidth' ] = 0
|
||||
buf.options[ 'omnifunc' ] = omnifunc
|
||||
buf.name = name
|
||||
|
||||
vim.eval( "prompt_setprompt( {0}, '{1}' )".format( buf.number,
|
||||
|
|
@ -156,6 +157,12 @@ def SetUpPromptBuffer( buf, name, prompt, callback ):
|
|||
buf.number,
|
||||
Escape( callback ) ) )
|
||||
|
||||
# This serves a few purposes, mainly to ensure that completion systems have
|
||||
# something to work with. In particular it makes YCM use its identifier engine
|
||||
# and you can config ycm to trigger semantic (annoyingly, synchronously) using
|
||||
# some let g:ycm_auto_trggier
|
||||
Call( 'setbufvar', buf.number, '&filetype', 'VimspectorPrompt' )
|
||||
|
||||
|
||||
def SetUpUIWindow( win ):
|
||||
win.options[ 'wrap' ] = False
|
||||
|
|
|
|||
|
|
@ -147,7 +147,8 @@ class VariablesView( object ):
|
|||
utils.SetUpPromptBuffer( self._watch.buf,
|
||||
'vimspector.Watches',
|
||||
'Expression: ',
|
||||
'vimspector#AddWatchPrompt' )
|
||||
'vimspector#AddWatchPrompt',
|
||||
'vimspector#OmniFuncWatch' )
|
||||
with utils.LetCurrentWindow( watches_win ):
|
||||
vim.command(
|
||||
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue