From f12f916255aa593562e7586c9a73ece6081cd099 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 23 Nov 2021 10:46:36 +0000 Subject: [PATCH] Adds ability to load templates in vim Will add to it at some point so I can view the template in fzf's preview --- nvim/.config/nvim/plugin/fzf.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nvim/.config/nvim/plugin/fzf.vim b/nvim/.config/nvim/plugin/fzf.vim index 46c35010..97c1b71f 100644 --- a/nvim/.config/nvim/plugin/fzf.vim +++ b/nvim/.config/nvim/plugin/fzf.vim @@ -9,3 +9,14 @@ nnoremap b = :FzfBuffers nnoremap h = :FzfHelptags " The space is important at the end of this mapping nnoremap / = :FzfRg + +function! s:read_template_into_buffer(template) + " has to be a function to avoid the extra space fzf#run insers otherwise + execute '0r ~/Templates/'.a:template +endfunction + +command! -bang -nargs=* LoadTemplate call fzf#run({ + \ 'source': 'ls -1 ~/Templates', + \ 'down': 20, + \ 'sink': function('read_template_into_buffer') + \ })