Make command line completion work too
This commit is contained in:
parent
45f0b68d87
commit
4e5011fe1b
1 changed files with 22 additions and 9 deletions
|
|
@ -240,25 +240,38 @@ function! vimspector#CompleteOutput( ArgLead, CmdLine, CursorPos ) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
py3 <<EOF
|
py3 <<EOF
|
||||||
def _vimspector_GetExprCompletions( CmdLine, CursorPos ):
|
def _vimspector_GetExprCompletions( ArgLead, prev_non_keyword_char ):
|
||||||
if not _vimspector_session:
|
if not _vimspector_session:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# FIXME
|
items = []
|
||||||
# Curiously, it seems that CursorPos is 0-based here and that's actually what
|
for candidate in _vimspector_session.GetCompletionsSync(
|
||||||
# the servers want/need ?
|
ArgLead,
|
||||||
return [ i.get( 'text' ) or i[ 'label' ]
|
prev_non_keyword_char ):
|
||||||
for i in _vimspector_session.GetCompletionsSync( CmdLine,
|
|
||||||
CursorPos ) ]
|
label = candidate.get( 'text', candidate[ 'label' ] )
|
||||||
|
|
||||||
|
start = prev_non_keyword_char - 1
|
||||||
|
|
||||||
|
if 'start' in candidate and 'length' in candidate:
|
||||||
|
start = candidate[ 'start' ]
|
||||||
|
|
||||||
|
items.append( ArgLead[ 0 : start ] + label )
|
||||||
|
|
||||||
|
return items
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
|
function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
|
||||||
if !s:enabled
|
if !s:enabled
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let col = len( a:ArgLead )
|
||||||
|
let prev_non_keyword_char = match( a:ArgLead[ 0 : col - 1 ], '\k*$' ) + 1
|
||||||
|
|
||||||
return join( py3eval( '_vimspector_GetExprCompletions( '
|
return join( py3eval( '_vimspector_GetExprCompletions( '
|
||||||
\.' vim.eval( "a:CmdLine" ),'
|
\ . 'vim.eval( "a:ArgLead" ), '
|
||||||
\.' int( vim.eval( "a:CursorPos" ) ) + 1 )' ),
|
\ . 'int( vim.eval( "prev_non_keyword_char" ) ) )' ),
|
||||||
\ "\n" )
|
\ "\n" )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue