Add some :commands for basic usages

This commit is contained in:
Ben Jackson 2020-01-09 20:53:59 +00:00
commit 7456c26c2a
5 changed files with 67 additions and 21 deletions

View file

@ -96,6 +96,11 @@ function! vimspector#AddWatchPrompt( expr ) abort
call vimspector#AddWatch( a:expr )
endfunction
function! vimspector#Evaluate( expr ) abort
py3 _vimspector_session.ShowOutput( 'Console' )
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ) )
endfunction
function! vimspector#EvaluateConsole( expr ) abort
stopinsert
setlocal nomodified
@ -110,6 +115,14 @@ function! vimspector#ListBreakpoints() abort
py3 _vimspector_session.ListBreakpoints()
endfunction
function! vimspector#CompleteOutput( ArgLead, CmdLine, CursorPos ) abort
return py3eval( '_vimspector_session.GetOutputBuffers()' )
endfunction
function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
return []
endfunction
" Boilerplate {{{
let &cpoptions=s:save_cpo
unlet s:save_cpo

View file

@ -126,8 +126,8 @@ function! vimspector#internal#neojob#StartCommandWithLog( cmd, category ) abort
let s:commands[ a:category ] = {}
endif
let stdout_buf = bufnr( '_vimspector_log_' . a:category . '_out', 1 )
let stderr_buf = bufnr( '_vimspector_log_' . a:category . '_err', 1 )
let stdout_buf = bufnr( '_vimspector_log_' . a:category . '_out', v:true )
let stderr_buf = bufnr( '_vimspector_log_' . a:category . '_err', v:true )
let id = jobstart(a:cmd,
\ {

View file

@ -26,6 +26,7 @@ if exists( 'g:loaded_vimpector' )
call s:restore_cpo()
finish
endif
"}}}
" TODO:
" - Check Vim version (for jobs)
@ -36,28 +37,54 @@ let g:loaded_vimpector = 1
let s:mappings = get( g:, 'vimspector_enable_mappings', '' )
nnoremap <Plug>VimspectorContinue :<c-u>call vimspector#Continue()<CR>
nnoremap <Plug>VimspectorStop :<c-u>call vimspector#Stop()<CR>
nnoremap <Plug>VimspectorRestart :<c-u>call vimspector#Restart()<CR>
nnoremap <Plug>VimspectorPause :<c-u>call vimspector#Pause()<CR>
nnoremap <Plug>VimspectorToggleBreakpoint
\ :<c-u>call vimspector#ToggleBreakpoint()<CR>
nnoremap <Plug>VimspectorAddFunctionBreakpoint
\ :<c-u>call vimspector#AddFunctionBreakpoint( expand( '<cexpr>' ) )<CR>
nnoremap <Plug>VimspectorStopOver :<c-u>call vimspector#StepOver()<CR>
nnoremap <Plug>VimspectorStepInto :<c-u>call vimspector#StepInto()<CR>
nnoremap <Plug>VimspectorStepOut :<c-u>call vimspector#StepOut()<CR>
if s:mappings ==# 'VISUAL_STUDIO'
nnoremap <F5> :call vimspector#Continue()<CR>
nnoremap <S-F5> :call vimspector#Stop()<CR>
nnoremap <C-S-F5> :call vimspector#Restart()<CR>
nnoremap <F6> :call vimspector#Pause()<CR>
nnoremap <F9> :call vimspector#ToggleBreakpoint()<CR>
nnoremap <S-F9> :call vimspector#AddFunctionBreakpoint( expand( '<cexpr>' ) )<CR>
nnoremap <F10> :call vimspector#StepOver()<CR>
nnoremap <F11> :call vimspector#StepInto()<CR>
nnoremap <S-F11> :call vimspector#StepOut()<CR>
nmap <F5> <Plug>VimspectorContinue
nmap <S-F5> <Plug>VimspectorStop
nmap <C-S-F5> <Plug>VimspectorRestart
nmap <F6> <Plug>VimspectorPause
nmap <F9> <Plug>VimspectorToggleBreakpoint
nmap <S-F9> <Plug>VimspectorAddFunctionBreakpoint
nmap <F10> <Plug>VimspectorStepOver
nmap <F11> <Plug>VimspectorStepInto
nmap <S-F11> <Plug>VimspectorStepOut
elseif s:mappings ==# 'HUMAN'
nnoremap <F5> :call vimspector#Continue()<CR>
nnoremap <F3> :call vimspector#Stop()<CR>
nnoremap <F4> :call vimspector#Restart()<CR>
nnoremap <F6> :call vimspector#Pause()<CR>
nnoremap <F9> :call vimspector#ToggleBreakpoint()<CR>
nnoremap <F8> :call vimspector#AddFunctionBreakpoint( expand( '<cexpr>' ) )<CR>
nnoremap <F10> :call vimspector#StepOver()<CR>
nnoremap <F11> :call vimspector#StepInto()<CR>
nnoremap <F12> :call vimspector#StepOut()<CR>
nmap <F5> <Plug>VimspectorContinue
nmap <F3> <Plug>VimspectorStop
nmap <F4> <Plug>VimspectorRestart
nmap <F6> <Plug>VimspectorPause
nmap <F9> <Plug>VimspectorToggleBreakpoint
nmap <F8> <Plug>VimspectorAddFunctionBreakpoint
nmap <F10> <Plug>VimspectorStepOver
nmap <F11> <Plug>VimspectorStepInto
nmap <F12> <Plug>VimspectorStepOut
endif
"}}}
command! -bar -nargs=1 -complete=customlist,vimspector#CompleteExpr
\ VimspectorWatch
\ call vimspector#AddWatch( <f-args> )
command! -bar -nargs=1 -complete=customlist,vimspector#CompleteOutput
\ VimspectorShowOutput
\ call vimspector#ShowOutput( <f-args> )
command! -bar -nargs=1 -complete=customlist,vimspector#CompleteExpr
\ VimspectorEval
\ call vimspector#Evaluate( <f-args> )
command! -bar
\ VimspectorReset
\ call vimspector#Reset()
" boilerplate {{{
call s:restore_cpo()
" }}}

View file

@ -403,6 +403,9 @@ class DebugSession( object ):
def ShowOutput( self, category ):
self._outputView.ShowOutput( category )
def GetOutputBuffers( self ):
return self._outputView.GetCategories()
def _SetUpUI( self ):
vim.command( 'tabnew' )
self._uiTab = vim.current.tabpage

View file

@ -206,3 +206,6 @@ class OutputView( object ):
tab_buffer.index,
utils.Escape( category ),
'*' if tab_buffer.flag else '' ) )
def GetCategories( self ):
return [ category for category in self._buffers.keys() ]