mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-18 02:05:57 +08:00
GitFiles?
This commit is contained in:
@@ -50,7 +50,8 @@ Commands
|
|||||||
| Command | List |
|
| Command | List |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `Files [PATH]` | Files (similar to `:FZF`) |
|
| `Files [PATH]` | Files (similar to `:FZF`) |
|
||||||
| `GitFiles` | Git files |
|
| `GitFiles` | Git files (git ls-files) |
|
||||||
|
| `GitFiles?` | Git files (git status) |
|
||||||
| `Buffers` | Open buffers |
|
| `Buffers` | Open buffers |
|
||||||
| `Colors` | Color schemes |
|
| `Colors` | Color schemes |
|
||||||
| `Ag [PATTERN]` | [ag][ag] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
|
| `Ag [PATTERN]` | [ag][ag] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
|
||||||
|
|||||||
@@ -357,18 +357,34 @@ function! fzf#vim#history(...)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
" GitFiles
|
" GitFiles[?]
|
||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
|
|
||||||
function! fzf#vim#gitfiles(...)
|
function! s:git_status_sink(lines) abort
|
||||||
|
if len(a:lines) < 2
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let lines = extend(a:lines[0:0], map(a:lines[1:], 'v:val[3:]'))
|
||||||
|
return s:common_sink(lines)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! fzf#vim#gitfiles(args, ...)
|
||||||
let root = systemlist('git rev-parse --show-toplevel')[0]
|
let root = systemlist('git rev-parse --show-toplevel')[0]
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
return s:warn('Not in git repo')
|
return s:warn('Not in git repo')
|
||||||
endif
|
endif
|
||||||
|
if a:args !~ '^?'
|
||||||
|
return s:fzf(fzf#vim#wrap({
|
||||||
|
\ 'source': 'git ls-files',
|
||||||
|
\ 'dir': root,
|
||||||
|
\ 'options': '-m --prompt "GitFiles> "'
|
||||||
|
\}), a:000)
|
||||||
|
endif
|
||||||
return s:fzf(fzf#vim#wrap({
|
return s:fzf(fzf#vim#wrap({
|
||||||
\ 'source': 'git ls-tree --name-only -r HEAD',
|
\ 'source': 'git -c color.status=always status --short',
|
||||||
\ 'dir': root,
|
\ 'dir': root,
|
||||||
\ 'options': '-m --prompt "GitFiles> "'
|
\ 'sink*': s:function('s:git_status_sink'),
|
||||||
|
\ 'options': '--ansi --multi --nth 2..,.. --prompt "GitFiles?> "'
|
||||||
\}), a:000)
|
\}), a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ COMMANDS *fzf-vim-commands*
|
|||||||
Command | List ~
|
Command | List ~
|
||||||
-----------------+-------------------------------------------------------------------
|
-----------------+-------------------------------------------------------------------
|
||||||
`Files [PATH]` | Files (similar to `:FZF` )
|
`Files [PATH]` | Files (similar to `:FZF` )
|
||||||
`GitFiles` | Git files
|
`GitFiles` | Git files (git ls-files)
|
||||||
|
`GitFiles?` | Git files (git status)
|
||||||
`Buffers` | Open buffers
|
`Buffers` | Open buffers
|
||||||
`Colors` | Color schemes
|
`Colors` | Color schemes
|
||||||
`Ag [PATTERN]` | {ag}{5} search result (ALT-A to select all, ALT-D to deselect all)
|
`Ag [PATTERN]` | {ag}{5} search result (ALT-A to select all, ALT-D to deselect all)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ endfunction
|
|||||||
|
|
||||||
call s:defs([
|
call s:defs([
|
||||||
\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, s:w(<bang>0))',
|
\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, s:w(<bang>0))',
|
||||||
\'command! -bang GitFiles call fzf#vim#gitfiles(s:w(<bang>0))',
|
\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(<q-args>, s:w(<bang>0))',
|
||||||
\'command! -bang Buffers call fzf#vim#buffers(s:w(<bang>0))',
|
\'command! -bang Buffers call fzf#vim#buffers(s:w(<bang>0))',
|
||||||
\'command! -bang Lines call fzf#vim#lines(s:w(<bang>0))',
|
\'command! -bang Lines call fzf#vim#lines(s:w(<bang>0))',
|
||||||
\'command! -bang BLines call fzf#vim#buffer_lines(s:w(<bang>0))',
|
\'command! -bang BLines call fzf#vim#buffer_lines(s:w(<bang>0))',
|
||||||
|
|||||||
Reference in New Issue
Block a user