From c0d4db23afa38d40f8b682d554082a4d89d0b431 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Thu, 2 Nov 2023 23:02:28 +0800 Subject: Support fzf to filter changed files --- .vim/after/plugin/fzf.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.vim/after/plugin/fzf.vim b/.vim/after/plugin/fzf.vim index 2101b90..0694caa 100644 --- a/.vim/after/plugin/fzf.vim +++ b/.vim/after/plugin/fzf.vim @@ -27,6 +27,10 @@ function! s:fzf_qf_sink(line) abort execute 'edit +' . line.lnum . ' ' . line.filename endfunction +let s:command_git_main_branch = 'git symbolic-ref --short refs/remotes/origin/HEAD' +let s:command_git_patch_files_changed = 'git diff --name-only --merge-base $(' + \ . s:command_git_main_branch . ')' + command! FzfQuickFix call fzf#run({ \ 'source': map(getqflist(), function('s:fzf_qf')), \ 'down': 20, @@ -42,6 +46,11 @@ if executable('fzf') && get(g:, 'loaded_fzf', 0) == 1 \ 'rg --hidden --column --line-number --no-heading --color=always --smart-case --glob !.git ' . , 1, \ fzf#vim#with_preview(), 0) + command! FzfGitChangedFiles call fzf#run({ + \ 'source': s:command_git_patch_files_changed, + \ 'sink': 'e' + \ }) + noremap ff :FzfFiles noremap fgf :FzfGFiles noremap fb :FzfBuffers @@ -49,8 +58,8 @@ if executable('fzf') && get(g:, 'loaded_fzf', 0) == 1 noremap ft :FzfBTags noremap fT :FzfTags noremap fr :FzfRg - noremap fc :FzfHistory: - noremap fC :FzfCommands + noremap fc :FzfCommands + nnoremap fC :FzfGitChangedFiles noremap fgc :FzfBCommits noremap fgC :FzfCommits noremap fl :FzfBLines -- cgit v1.2.3