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:
Ben Jackson 2020-09-03 17:46:06 +01:00
commit 733843a6d4
5 changed files with 113 additions and 8 deletions

View file

@ -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