Include selecta

This commit is contained in:
Max Bucknell 2018-01-21 00:57:21 +00:00
parent 13cefee2c6
commit 0f50476c80

View file

@ -101,6 +101,25 @@ endfunction
nnoremap <c-t> :exec ":e " . FindTestFilename(expand('%')) <cr>
" Run a given vim command on the results of fuzzy selecting from a given shell
" command. See usage below.
function! SelectaCommand(choice_command, selecta_args, vim_command)
try
let selection = system(a:choice_command . " | selecta " . a:selecta_args)
catch /Vim:Interrupt/
" Swallow the ^C so that the redraw below happens; otherwise there will be
" leftovers from selecta on the screen
redraw!
return
endtry
redraw!
exec a:vim_command . " " . selection
endfunction
" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
nnoremap <leader>t :call SelectaCommand("find * -type f", "", ":e")<cr>
" Git blame
"
" I used to do this by just filling in my buffer, but this is nicer.