I've been messing around a bit with fzf
and I'd like to be able to run a command that does something like take the output of diff -w -M origin/main...HEAD --name-only
and make the contents available in a preview window.
I've gotten this far, with some copy/paste from the docs:
command! -bang -nargs=* Gdomo
\ call fzf#vim#grep(
\ 'git diff -w -M origin/main...HEAD --name-only', 0,
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0))
That gets me the preview window, but selecting any of the files results in:
Error detected while processing function 24[30]..<SNR>53_callback[23]..function 24[30]..<SNR>53_callback:
line 21:
Vim(let):E684: list index out of range: 1
I'm guessing that trying to wrap grep
is my first mistake, but I've looked at the plugin code and it's not clear to me what a better approach would be.
:h :GFiles
which is built-in in fzf.vim and which opens the not staged files? And if:GFiles
is not exactly what you're looking for you can either give it more arguments or look at fzf#vim#gitfiles code which should give your enough inspiration to do what you want.:GFiles
is not quite what I'm looking for. I want a preview window with just the files in a branch which have diverged frommain
, even if there are no unstaged changes. This helps me quickly find, for example, a unit test which I want to tweak or just continue to work on files that I care about which are not currently open in a buffer. I'll have a closer look atfzf#vim#gitfiles
.