all repos — dotfiles @ 907ad7148dddec42acd9492595ab8efc624efa5e

my *nix dotfiles

Integrate fzy with vim
Anirudh Oppiliappan x@icyphox.sh
Mon, 02 Nov 2020 09:14:26 +0530
commit

907ad7148dddec42acd9492595ab8efc624efa5e

parent

1cf967a74be325145887e4c2b59094e1496f41e2

2 files changed, 36 insertions(+), 0 deletions(-)

jump to
A config/nvim/plugin/fzy.vim

@@ -0,0 +1,30 @@

+let g:fzy_loaded=0 + +function! s:completed(winid, filename, action, ...) abort + bdelete! + call win_gotoid(a:winid) + if filereadable(a:filename) + let lines = readfile(a:filename) + if !empty(lines) + exe a:action . ' ' . lines[0] + endif + call delete(a:filename) + endif +endfunction + +function! FzyCommand(choice_command, vim_command) + let file = tempname() + let winid = win_getid() + let cmd = split(&shell) + split(&shellcmdflag) + [a:choice_command . ' | fzy > ' . file] + let F = function('s:completed', [winid, file, a:vim_command]) + botright 10 new + if has('nvim') + call termopen(cmd, {'on_exit': F}) + else + call term_start(cmd, {'exit_cb': F, 'curwin': 1}) + endif + startinsert +endfunction + +let g:fzy_loaded=1 +
M config/nvim/plugin/maps.vimconfig/nvim/plugin/maps.vim

@@ -15,3 +15,9 @@ :command! Wqa wqa

:command! W w :command! Q q +" check if fzy is loaded and in PATH +if executable('fzy') && fzy_loaded + nnoremap <leader>e :call FzyCommand("find . -type f", ":e")<cr> + nnoremap <leader>v :call FzyCommand("find . -type f", ":vs")<cr> + nnoremap <leader>s :call FzyCommand("find . -type f", ":sp")<cr> +endif