mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +00:00
parent
2a167aa030
commit
e865144ace
@ -275,6 +275,10 @@ If you have set up fzf for Vim, `:FZF` command will be added.
|
||||
:FZF --no-sort -m /tmp
|
||||
```
|
||||
|
||||
Similarly to [ctrlp.vim](https://github.com/kien/ctrlp.vim), use enter key,
|
||||
`CTRL-T`, `CTRL-X` or `CTRL-V` to open selected files in the current window,
|
||||
in new tabs, in horizontal splits, or in vertical splits respectively.
|
||||
|
||||
Note that the environment variables `FZF_DEFAULT_COMMAND` and `FZF_DEFAULT_OPTS`
|
||||
also apply here.
|
||||
|
||||
|
@ -26,6 +26,7 @@ let s:launcher = 'xterm -e bash -ic %s'
|
||||
let s:fzf_go = expand('<sfile>:h:h').'/bin/fzf'
|
||||
let s:fzf_rb = expand('<sfile>:h:h').'/fzf'
|
||||
let s:fzf_tmux = expand('<sfile>:h:h').'/bin/fzf-tmux'
|
||||
let s:legacy = 0
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
@ -40,6 +41,7 @@ function! s:fzf_exec()
|
||||
let s:exec = path[0]
|
||||
elseif executable(s:fzf_rb)
|
||||
let s:exec = s:fzf_rb
|
||||
let s:legacy = 1
|
||||
else
|
||||
call system('type fzf')
|
||||
if v:shell_error
|
||||
@ -221,7 +223,7 @@ function! s:callback(dict, temps)
|
||||
if type(a:dict.sink) == 2
|
||||
call a:dict.sink(line)
|
||||
else
|
||||
execute a:dict.sink.' '.s:escape(line)
|
||||
execute a:dict.sink s:escape(line)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
@ -238,6 +240,9 @@ endfunction
|
||||
|
||||
function! s:cmd(bang, ...) abort
|
||||
let args = copy(a:000)
|
||||
if !s:legacy
|
||||
let args = add(args, '--expect=ctrl-t,ctrl-x,ctrl-v')
|
||||
endif
|
||||
let opts = {}
|
||||
if len(args) > 0 && isdirectory(expand(args[-1]))
|
||||
let opts.dir = remove(args, -1)
|
||||
@ -245,7 +250,24 @@ function! s:cmd(bang, ...) abort
|
||||
if !a:bang
|
||||
let opts.down = get(g:, 'fzf_tmux_height', s:default_tmux_height)
|
||||
endif
|
||||
call fzf#run(extend({ 'sink': 'e', 'options': join(args) }, opts))
|
||||
|
||||
if s:legacy
|
||||
call fzf#run(extend({ 'sink': 'e', 'options': join(args) }, opts))
|
||||
else
|
||||
let output = fzf#run(extend({ 'options': join(args) }, opts))
|
||||
if empty(output)
|
||||
return
|
||||
endif
|
||||
let key = remove(output, 0)
|
||||
if key == 'ctrl-t' | let cmd = 'tabedit'
|
||||
elseif key == 'ctrl-x' | let cmd = 'split'
|
||||
elseif key == 'ctrl-v' | let cmd = 'vsplit'
|
||||
else | let cmd = 'e'
|
||||
endif
|
||||
for item in output
|
||||
execute cmd s:escape(item)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
command! -nargs=* -complete=dir -bang FZF call s:cmd('<bang>' == '!', <f-args>)
|
||||
|
Loading…
Reference in New Issue
Block a user