mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-09 08:32:01 -07:00
@@ -275,6 +275,10 @@ If you have set up fzf for Vim, `:FZF` command will be added.
|
|||||||
:FZF --no-sort -m /tmp
|
: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`
|
Note that the environment variables `FZF_DEFAULT_COMMAND` and `FZF_DEFAULT_OPTS`
|
||||||
also apply here.
|
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_go = expand('<sfile>:h:h').'/bin/fzf'
|
||||||
let s:fzf_rb = expand('<sfile>:h:h').'/fzf'
|
let s:fzf_rb = expand('<sfile>:h:h').'/fzf'
|
||||||
let s:fzf_tmux = expand('<sfile>:h:h').'/bin/fzf-tmux'
|
let s:fzf_tmux = expand('<sfile>:h:h').'/bin/fzf-tmux'
|
||||||
|
let s:legacy = 0
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@@ -40,6 +41,7 @@ function! s:fzf_exec()
|
|||||||
let s:exec = path[0]
|
let s:exec = path[0]
|
||||||
elseif executable(s:fzf_rb)
|
elseif executable(s:fzf_rb)
|
||||||
let s:exec = s:fzf_rb
|
let s:exec = s:fzf_rb
|
||||||
|
let s:legacy = 1
|
||||||
else
|
else
|
||||||
call system('type fzf')
|
call system('type fzf')
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
@@ -221,7 +223,7 @@ function! s:callback(dict, temps)
|
|||||||
if type(a:dict.sink) == 2
|
if type(a:dict.sink) == 2
|
||||||
call a:dict.sink(line)
|
call a:dict.sink(line)
|
||||||
else
|
else
|
||||||
execute a:dict.sink.' '.s:escape(line)
|
execute a:dict.sink s:escape(line)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
@@ -238,6 +240,9 @@ endfunction
|
|||||||
|
|
||||||
function! s:cmd(bang, ...) abort
|
function! s:cmd(bang, ...) abort
|
||||||
let args = copy(a:000)
|
let args = copy(a:000)
|
||||||
|
if !s:legacy
|
||||||
|
let args = add(args, '--expect=ctrl-t,ctrl-x,ctrl-v')
|
||||||
|
endif
|
||||||
let opts = {}
|
let opts = {}
|
||||||
if len(args) > 0 && isdirectory(expand(args[-1]))
|
if len(args) > 0 && isdirectory(expand(args[-1]))
|
||||||
let opts.dir = remove(args, -1)
|
let opts.dir = remove(args, -1)
|
||||||
@@ -245,7 +250,24 @@ function! s:cmd(bang, ...) abort
|
|||||||
if !a:bang
|
if !a:bang
|
||||||
let opts.down = get(g:, 'fzf_tmux_height', s:default_tmux_height)
|
let opts.down = get(g:, 'fzf_tmux_height', s:default_tmux_height)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if s:legacy
|
||||||
call fzf#run(extend({ 'sink': 'e', 'options': join(args) }, opts))
|
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
|
endfunction
|
||||||
|
|
||||||
command! -nargs=* -complete=dir -bang FZF call s:cmd('<bang>' == '!', <f-args>)
|
command! -nargs=* -complete=dir -bang FZF call s:cmd('<bang>' == '!', <f-args>)
|
||||||
|
Reference in New Issue
Block a user