Last active
December 12, 2018 19:53
-
-
Save coryf/87adb964b3ca1163fbc8081f62a488c2 to your computer and use it in GitHub Desktop.
Vim ripgrep and fzy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ripgrep | |
" https://github.com/BurntSushi/ripgrep | |
set grepprg=rg\ --vimgrep\ --no-heading | |
set grepformat^=%f:%l:%c:%m | |
command -nargs=+ -complete=file Rg silent! grep! <args> | copen | redraw! | |
nmap <silent> <leader>a :Rg "\b<C-R><C-W>\b"<CR> | |
" fzy - fuzzy find | |
" https://github.com/jhawthorn/fzy | |
function! FzyCommand(choice_command, vim_command) | |
try | |
let output = system(a:choice_command . " | fzy ") | |
catch /Vim:Interrupt/ | |
" Swallow errors from ^C, allow redraw! below | |
endtry | |
redraw! | |
if v:shell_error == 0 && !empty(output) | |
exec a:vim_command . ' ' . output | |
endif | |
endfunction | |
nnoremap <leader>t :call FzyCommand("rg . -l -g ''", ":e")<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ripgrep: https://github.com/BurntSushi/ripgrep
fzy: https://github.com/jhawthorn/fzy