From 5a54e35b77fbcea65a67ee3916704872769012d6 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 20 May 2023 17:52:47 -0400 Subject: [PATCH] nvim: add eval bind for vimspector --- src/.config/nvim/init.vim | 2 -- src/.config/nvim/vimspector.vim | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/.config/nvim/init.vim b/src/.config/nvim/init.vim index 793c88d..d448a06 100755 --- a/src/.config/nvim/init.vim +++ b/src/.config/nvim/init.vim @@ -44,8 +44,6 @@ nnoremap :noh " shortcuts to type symbols easier source $XDG_CONFIG_HOME/nvim/digraphs.vim -vnoremap K :'<,'>Evaluate - " tab, window management set splitbelow splitright nnoremap w diff --git a/src/.config/nvim/vimspector.vim b/src/.config/nvim/vimspector.vim index ccfc471..65d071f 100644 --- a/src/.config/nvim/vimspector.vim +++ b/src/.config/nvim/vimspector.vim @@ -36,12 +36,13 @@ nnoremap rw :call WriteInput() " feed from input file into program stdin function RunInput() + let l:winid = win_getid() call win_gotoid(g:vimspector_session_windows.code) - let inputfile=$HOME .. "/.cache/termdebug/input/" .. expand("%:r") - let @x = join(readfile(inputfile), "\n") .. "\n\n" + let l:inputfile=$HOME .. "/.cache/termdebug/input/" .. expand("%:r") + let @x = join(readfile(l:inputfile), "\n") .. "\n\n" call win_gotoid(g:vimspector_session_windows.terminal) normal G"xp - call win_gotoid(g:vimspector_session_windows.code) + call win_gotoid(l:winid) endfunction nnoremap ri :call RunInput() @@ -49,6 +50,14 @@ nnoremap ri :call RunInput() nnoremap rs :call vimspector#Restart() nnoremap rr :call vimspector#Stop() nnoremap rf :call vimspector#Continue() +" codelldb breaks if you just restart directly +func VimspectorHardRestart() + call vimspector#Stop() + sleep 100m + call vimspector#Restart() +endfunc +nnoremap rt :call VimspectorHardRestart() + nnoremap :call vimspector#StepInto() nnoremap :call vimspector#StepOver() @@ -58,3 +67,12 @@ nnoremap dsc :call vimspector#ClearBreakpoints() " watches au BufEnter vimspector.Watches* nnoremap dd :call vimspector#DeleteWatch() + +func VimspectorEval() + let l:winid = win_getid() + normal gv"xy + call win_gotoid(g:vimspector_session_windows.output) + execute "normal! ip " . @x . "\n\" + call win_gotoid(l:winid) +endfunc +vnoremap K :call VimspectorEval()