Add Files command

This commit is contained in:
Junegunn Choi 2015-08-16 00:09:22 +09:00
parent 63fc2490d8
commit 4128925e3e
2 changed files with 29 additions and 0 deletions

View file

@ -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) |

View file

@ -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
" ------------------------------------------------------------------