diff options
author | Guangxiong Lin <[email protected]> | 2023-11-02 23:02:28 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2023-11-02 23:02:28 +0800 |
commit | c0d4db23afa38d40f8b682d554082a4d89d0b431 (patch) | |
tree | 976e9157e3a906e2729d3f844a311926d26e23e8 | |
parent | 83da08318377c62ce3bc472553d4c693d8c7a51b (diff) | |
download | dotfiles-c0d4db23afa38d40f8b682d554082a4d89d0b431.tar.gz dotfiles-c0d4db23afa38d40f8b682d554082a4d89d0b431.tar.bz2 dotfiles-c0d4db23afa38d40f8b682d554082a4d89d0b431.zip |
Support fzf to filter changed files
-rw-r--r-- | .vim/after/plugin/fzf.vim | 13 |
1 files 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 ' . <q-args>, 1, \ fzf#vim#with_preview(), <bang>0) + command! FzfGitChangedFiles call fzf#run({ + \ 'source': s:command_git_patch_files_changed, + \ 'sink': 'e' + \ }) + noremap <leader>ff :FzfFiles<CR> noremap <leader>fgf :FzfGFiles<CR> noremap <leader>fb :FzfBuffers<CR> @@ -49,8 +58,8 @@ if executable('fzf') && get(g:, 'loaded_fzf', 0) == 1 noremap <leader>ft :FzfBTags<CR> noremap <leader>fT :FzfTags<CR> noremap <leader>fr :FzfRg<space> - noremap <leader>fc :FzfHistory:<CR> - noremap <leader>fC :FzfCommands<CR> + noremap <leader>fc :FzfCommands<CR> + nnoremap <leader>fC :FzfGitChangedFiles<CR> noremap <leader>fgc :FzfBCommits<CR> noremap <leader>fgC :FzfCommits<CR> noremap <leader>fl :FzfBLines<CR> |