This is the minimal required for a user to use conditional breakpoint - we add an options dict to each breakpoint (line and function) and allow the condition to be supplied. We add a plug mapping and a default shortcut (<leader><F9>) to add one where we ask the user to enter the condition and hit expression. This isn't great but it works. We don't check the capabilities, so they would just be ignored if used on a server that doesn't support them. We also ask for a hit expression which most users won't understand so this isn't ideal either. No tests yet.
96 lines
3.5 KiB
VimL
96 lines
3.5 KiB
VimL
" vimspector - A multi-language debugging system for Vim
|
|
" Copyright 2018 Ben Jackson
|
|
"
|
|
" Licensed under the Apache License, Version 2.0 (the "License");
|
|
" you may not use this file except in compliance with the License.
|
|
" You may obtain a copy of the License at
|
|
"
|
|
" http://www.apache.org/licenses/LICENSE-2.0
|
|
"
|
|
" Unless required by applicable law or agreed to in writing, software
|
|
" distributed under the License is distributed on an "AS IS" BASIS,
|
|
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
" See the License for the specific language governing permissions and
|
|
" limitations under the License.
|
|
|
|
" Boilerplate {{{
|
|
let s:save_cpo = &cpoptions
|
|
set cpoptions&vim
|
|
|
|
function! s:restore_cpo()
|
|
let &cpoptions=s:save_cpo
|
|
unlet s:save_cpo
|
|
endfunction
|
|
|
|
if exists( 'g:loaded_vimpector' )
|
|
call s:restore_cpo()
|
|
finish
|
|
endif
|
|
"}}}
|
|
|
|
" TODO:
|
|
" - Check Vim version (for jobs)
|
|
" - Check python support
|
|
" - Add commands/mappings/menus?
|
|
|
|
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>VimspectorToggleConditionalBreakpoint
|
|
\ :<c-u>call vimspector#ToggleBreakpoint(
|
|
\ { 'condition': input( 'Enter condition: ' ),
|
|
\ 'hitCondition': input( 'Enter hit condition: ' ) }
|
|
\ )<CR>
|
|
nnoremap <Plug>VimspectorAddFunctionBreakpoint
|
|
\ :<c-u>call vimspector#AddFunctionBreakpoint( expand( '<cexpr>' ) )<CR>
|
|
nnoremap <Plug>VimspectorStepOver :<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'
|
|
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'
|
|
nmap <F5> <Plug>VimspectorContinue
|
|
nmap <F3> <Plug>VimspectorStop
|
|
nmap <F4> <Plug>VimspectorRestart
|
|
nmap <F6> <Plug>VimspectorPause
|
|
nmap <F9> <Plug>VimspectorToggleBreakpoint
|
|
nmap <leader><F9> <Plug>VimspectorToggleConditionalBreakpoint
|
|
nmap <F8> <Plug>VimspectorAddFunctionBreakpoint
|
|
nmap <F10> <Plug>VimspectorStepOver
|
|
nmap <F11> <Plug>VimspectorStepInto
|
|
nmap <F12> <Plug>VimspectorStepOut
|
|
endif
|
|
|
|
command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
|
|
\ VimspectorWatch
|
|
\ call vimspector#AddWatch( <f-args> )
|
|
command! -bar -nargs=1 -complete=custom,vimspector#CompleteOutput
|
|
\ VimspectorShowOutput
|
|
\ call vimspector#ShowOutput( <f-args> )
|
|
command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
|
|
\ VimspectorEval
|
|
\ call vimspector#Evaluate( <f-args> )
|
|
command! -bar
|
|
\ VimspectorReset
|
|
\ call vimspector#Reset()
|
|
|
|
" boilerplate {{{
|
|
call s:restore_cpo()
|
|
" }}}
|
|
|