Last active
May 6, 2018 21:27
-
-
Save jarednorman/9c56fd9eb14784e5ac277afb861fd8be to your computer and use it in GitHub Desktop.
Search for a gem in the current project, and then search for (and open) a file within it (from Vim, requires fzf.vim)
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
" Gem search | |
function! GemSearch() | |
call fzf#run(fzf#wrap({'source': "bundle list | sed '1d;$d' | cut -d ' ' -f 4", 'sink': {gem -> GemFileSearch(gem)}})) | |
endfunction | |
function! GemFileSearch(gem) | |
let gemdir = substitute(system("bundle show " . a:gem), '\n\+$', '', '') | |
call fzf#run(fzf#wrap({'source': 'rg --files ' . gemdir . ' --color never | sed -e "s#^' . gemdir . '/##"', 'dir': gemdir})) | |
endfunction | |
nnoremap <leader>gf :call GemSearch()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment