2
0
mirror of https://github.com/junegunn/fzf synced 2024-11-14 18:12:53 +00:00

[vim] Apply --multi and --prompt to :FZF command

This commit is contained in:
Junegunn Choi 2016-10-04 00:20:36 +09:00
parent 3066b206af
commit 01b88539ba
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 8 additions and 4 deletions

View File

@ -305,7 +305,7 @@ If you have set up fzf for Vim, `:FZF` command will be added.
:FZF ~ :FZF ~
" With options " With options
:FZF --no-sort -m /tmp :FZF --no-sort --reverse --inline-info /tmp
" Bang version starts in fullscreen instead of using tmux pane or Neovim split " Bang version starts in fullscreen instead of using tmux pane or Neovim split
:FZF! :FZF!

View File

@ -558,11 +558,15 @@ let s:default_action = {
function! s:cmd(bang, ...) abort function! s:cmd(bang, ...) abort
let args = copy(a:000) let args = copy(a:000)
let opts = {} let opts = { 'options': '--multi ' }
if len(args) && isdirectory(expand(args[-1])) if len(args) && isdirectory(expand(args[-1]))
let opts.dir = substitute(remove(args, -1), '\\\(["'']\)', '\1', 'g') let opts.dir = substitute(substitute(remove(args, -1), '\\\(["'']\)', '\1', 'g'), '/*$', '/', '')
let opts.options .= ' --prompt '.shellescape(opts.dir)
else
let opts.options .= ' --prompt '.shellescape(pathshorten(getcwd()).'/')
endif endif
call fzf#run(fzf#wrap('FZF', extend({'options': join(args)}, opts), a:bang)) let opts.options .= ' '.join(args)
call fzf#run(fzf#wrap('FZF', opts, a:bang))
endfunction endfunction
command! -nargs=* -complete=dir -bang FZF call s:cmd(<bang>0, <f-args>) command! -nargs=* -complete=dir -bang FZF call s:cmd(<bang>0, <f-args>)