Skip to content

Instantly share code, notes, and snippets.

@rvighne
Created May 24, 2022 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvighne/99c98080e79cbd2fdf9d4a097c783e9d to your computer and use it in GitHub Desktop.
Save rvighne/99c98080e79cbd2fdf9d4a097c783e9d to your computer and use it in GitHub Desktop.
fzf.vim is great, but its :GFiles always assumes that .git is in a particular place. It can be made more robust to this and other edge cases by integrating with Fugitive, which already abstracts the details of interacting with Git.
" Alternative to GFiles: integrate with Fugitive to work better in edge cases
" Completion should actually be pathspec, not file, but close enough
command -bang -nargs=* -complete=file FugitiveFiles
\ call fzf#run(fzf#wrap('gfiles', fzf#vim#with_preview({
\ 'source': FugitiveShellCommand('ls-files', '-z', '--', <f-args>),
\ 'options': '--read0 --multi --no-clear --prompt=' . shellescape('FugitiveFiles> ')
\ }), <bang>0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment