From 1a2d597045525b9ed0046cc38333deaa27eec7b8 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Fri, 30 Oct 2015 12:05:54 -0400 Subject: [PATCH] Add GitFiles command --- README.md | 1 + autoload/fzf/vim.vim | 12 ++++++++++++ doc/fzf-vim.txt | 1 + plugin/fzf.vim | 1 + 4 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 3c6b3f2..392bf8a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Commands | Command | List | | --- | --- | | `Files [PATH]` | Files (similar to `:FZF`) | +| `GitFiles` | Git files | `Buffers` | Open buffers | | `Colors` | Color schemes | | `Ag [PATTERN]` | [ag][ag] search result (`CTRL-A` to select all, `CTRL-D` to deselect all) | diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index e3a90ce..8a028d4 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -323,6 +323,18 @@ function! fzf#vim#history(...) \}, a:000) endfunction +" ------------------------------------------------------------------ +" GitFiles +" ------------------------------------------------------------------ + +function! fzf#vim#gitfiles(...) + call s:fzf({ + \ 'source': 'git ls-tree --name-only -r HEAD', + \ 'sink*': s:function('s:common_sink'), + \ 'options': '--prompt "GitFiles> " -m'.s:expect(), + \}, a:000) +endfunction + " ------------------------------------------------------------------ " Buffers " ------------------------------------------------------------------ diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt index d5bc06a..2427965 100644 --- a/doc/fzf-vim.txt +++ b/doc/fzf-vim.txt @@ -75,6 +75,7 @@ COMMANDS *fzf-vim-commands* Command | List ~ -----------------+--------------------------------------------------------------------- `Files [PATH]` | Files (similar to `:FZF` ) + `GitFiles` | Git files `Buffers` | Open buffers `Colors` | Color schemes `Ag [PATTERN]` | {ag}{5} search result (CTRL-A to select all, CTRL-D to deselect all) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 89f36d3..c4f0673 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -43,6 +43,7 @@ endfunction call s:defs([ \'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, s:w(0))', +\'command! -bang GitFiles call fzf#vim#gitfiles(s:w(0))', \'command! -bang Buffers call fzf#vim#buffers(s:w(0))', \'command! -bang Lines call fzf#vim#lines(s:w(0))', \'command! -bang BLines call fzf#vim#buffer_lines(s:w(0))',