From fd606aa4658929c1d2a5fbb9737a38858042e50a Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sun, 21 Jun 2020 16:43:48 +0530 Subject: [PATCH] nvim: keymappings: Add enhanced helper for ijump Signed-off-by: Sanchayan Maity --- nvim/.config/nvim/keymappings.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nvim/.config/nvim/keymappings.vim b/nvim/.config/nvim/keymappings.vim index a940cd8..fcba047 100644 --- a/nvim/.config/nvim/keymappings.vim +++ b/nvim/.config/nvim/keymappings.vim @@ -173,3 +173,17 @@ inoremap " Asynchronous make command! -bang -nargs=* -complete=file Make call asyncdo#run(0, &makeprg, ) command! -bang -nargs=* -complete=file LMake call asyncdo#lrun(0, &makeprg, ) + +nnoremap [i [I:call PromptAndExec(":ijump! %d \022\027\015") +nnoremap ]i ]I:call PromptAndExec(":+1,$ijump! %d \022\027\015") + +function! s:PromptAndExec(cmd) abort + let ans = input('Type number and (empty cancels): ') + + if ans !~# '^\s*$' + try + silent execute 'normal! ' . printf(a:cmd, ans) + catch /E387/ "E387: Match is on current line + endtry + endif +endfunction