mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-01-20 18:14:34 +08:00
Add Files command
This commit is contained in:
@@ -32,6 +32,7 @@ List of commands
|
||||
|
||||
| Command | List |
|
||||
| --- | --- |
|
||||
| `Files [PATH]` | Files (similar to `:FZF`) |
|
||||
| `Buffers` | Open buffers |
|
||||
| `Colors` | Color schemes |
|
||||
| `Ag [PATTERN]` | [ag][ag] search result (`CTRL-A` to select all, `CTRL-D` to deselect all) |
|
||||
|
||||
@@ -94,6 +94,34 @@ function! s:align_lists(lists)
|
||||
return a:lists
|
||||
endfunction
|
||||
|
||||
" ------------------------------------------------------------------
|
||||
" Files
|
||||
" ------------------------------------------------------------------
|
||||
function! s:files(dir, bang)
|
||||
let args = {
|
||||
\ 'sink*': function('s:common_sink'),
|
||||
\ 'options': '-m'.s:expect()
|
||||
\}
|
||||
|
||||
if !empty(a:dir)
|
||||
if !isdirectory(expand(a:dir))
|
||||
echohl WarningMsg
|
||||
echom 'Invalid directory'
|
||||
echohl None
|
||||
return
|
||||
endif
|
||||
let dir = substitute(a:dir, '/*$', '/', '')
|
||||
let args.dir = dir
|
||||
let args.options .= ' --prompt '.shellescape(dir)
|
||||
else
|
||||
let args.options .= ' --prompt "./"'
|
||||
endif
|
||||
|
||||
call s:fzf(args, a:bang)
|
||||
endfunction
|
||||
|
||||
command! -bang -nargs=? -complete=dir Files call s:files(<q-args>, <bang>0)
|
||||
|
||||
" ------------------------------------------------------------------
|
||||
" Lines
|
||||
" ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user