all repos — dotfiles @ bef8a45c75b86ea37b1aa312eab1b9d7ac07009f

my *nix dotfiles

config/nvim/plugin/fzy.vim (view raw)

 1let g:fzy_loaded=0
 2
 3function! s:completed(winid, filename, action, ...) abort
 4    bdelete!
 5    call win_gotoid(a:winid)
 6    if filereadable(a:filename)
 7      let lines = readfile(a:filename)
 8      if !empty(lines)
 9        exe a:action . ' ' . lines[0]
10      endif
11      call delete(a:filename)
12    endif
13endfunction
14
15function! FzyCommand(choice_command, vim_command)
16    let file = tempname()
17    let winid = win_getid()
18    let cmd = split(&shell) + split(&shellcmdflag) + [a:choice_command . ' | fzy > ' . file]
19    let F = function('s:completed', [winid, file, a:vim_command])
20    botright 10 new
21    if has('nvim')
22        call termopen(cmd, {'on_exit': F})
23    else
24        call term_start(cmd, {'exit_cb': F, 'curwin': 1})
25    endif
26    startinsert
27endfunction
28
29let g:fzy_loaded=1
30