mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-08-31 03:46:57 +08:00
Compare commits
24
Commits
98dcd77a18
...
show-key
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a9f08fb36 | ||
|
|
a92f1cce23 | ||
|
|
05b2324b75 | ||
|
|
c63f25a2ba | ||
|
|
e541ce6037 | ||
|
|
cb6ea5e06f | ||
|
|
4ae5a659f8 | ||
|
|
b83a8e5ddd | ||
|
|
091f9c92f9 | ||
|
|
a246483a09 | ||
|
|
d2a59a992a | ||
|
|
356608e2ae | ||
|
|
7fd26e3609 | ||
|
|
c2b97c62b9 | ||
|
|
e5b53de3d3 | ||
|
|
11d44b1805 | ||
|
|
b9b98ac574 | ||
|
|
31e338e314 | ||
|
|
28ed21ef3e | ||
|
|
b9624aa012 | ||
|
|
34a564c81f | ||
|
|
ddc14a6a54 | ||
|
|
879db51d09 | ||
|
|
3725f364cc |
@@ -96,6 +96,20 @@ Commands
|
||||
|
||||
- Most commands support `CTRL-T` / `CTRL-X` / `CTRL-V` key
|
||||
bindings to open in a new tab, a new split, or in a new vertical split
|
||||
- Most commands support `ALT-ENTER` to insert the selected items into the
|
||||
current buffer instead of opening them. The inserted text depends on the
|
||||
command: file path (`:Files`, `:GFiles`, `:Buffers`, `:History`, `:Locate`),
|
||||
line content (`:Lines`, `:BLines`, `:Marks`, `:Changes`), matched text
|
||||
(`:Rg`, `:Ag`, `:Grep`), tag name (`:Tags`, `:BTags`), or commit hash
|
||||
(`:Commits`, `:BCommits`)
|
||||
- Most commands support `CTRL-O` to open the current entry in the window fzf
|
||||
was started from, leaving fzf open, so you can look through several entries
|
||||
in a single run (`:Files`, `:GFiles`, `:Buffers`, `:History`, `:Locate`,
|
||||
`:Rg`, `:Ag`, `:Grep`, `:Lines`, `:BLines`, `:Tags`, `:BTags`, `:Marks`,
|
||||
`:Changes`). Requires fzf 0.74.4 or later, and is not offered in fullscreen
|
||||
mode, with a layout that leaves no other window (`enew`, `tabnew`), on
|
||||
Windows, or when the key is already used by `g:fzf_vim.paste_key`,
|
||||
`g:fzf_action`, or the command itself, as `CTRL-ALT-X` is in `:Buffers`
|
||||
- Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen
|
||||
- You can set `g:fzf_vim.command_prefix` to give the same prefix to the commands
|
||||
- e.g. `let g:fzf_vim.command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
|
||||
@@ -156,6 +170,36 @@ let g:fzf_vim.preview_window = []
|
||||
" let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'
|
||||
```
|
||||
|
||||
#### Paste key
|
||||
|
||||
Most commands support a key to insert the selected items into the current
|
||||
buffer instead of opening them (see the command list above for what each
|
||||
command inserts). Customize it with `g:fzf_vim.paste_key`.
|
||||
|
||||
```vim
|
||||
" Key to insert the selected items into the current buffer (default: 'alt-enter')
|
||||
let g:fzf_vim.paste_key = 'alt-enter'
|
||||
```
|
||||
|
||||
#### Show key
|
||||
|
||||
Most commands support a key that opens the current entry in the window fzf
|
||||
was started from and leaves fzf open, so you can look through several entries
|
||||
in one run (see the command list above). It is labelled `Show` in the footer
|
||||
to set it apart from `Enter`, which opens the entry and closes fzf. Customize
|
||||
it with `g:fzf_vim.show_key`, or set it to an empty string to turn the key
|
||||
off. A comma-separated list binds every key in it. It takes the key over from
|
||||
`$FZF_DEFAULT_OPTS`, so pick another key or turn it off to keep a binding of
|
||||
your own.
|
||||
|
||||
```vim
|
||||
" Key to open the current entry, leaving fzf open (default: 'ctrl-o')
|
||||
let g:fzf_vim.show_key = 'ctrl-o'
|
||||
|
||||
" Use CTRL-O and double-click
|
||||
let g:fzf_vim.show_key = 'ctrl-o,double-click'
|
||||
```
|
||||
|
||||
#### Command-level options
|
||||
|
||||
```vim
|
||||
|
||||
+688
-109
File diff suppressed because it is too large
Load Diff
+72
-31
@@ -28,6 +28,9 @@ function! s:warn(message)
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Channels in flight, keyed by fifo path, so concurrent fzf runs do not clash
|
||||
let s:channels = {}
|
||||
|
||||
function! fzf#vim#ipc#start(Callback)
|
||||
if !exists('*job_start') && !exists('*jobstart')
|
||||
call s:warn('job_start/jobstart function not supported')
|
||||
@@ -39,57 +42,95 @@ function! fzf#vim#ipc#start(Callback)
|
||||
return ''
|
||||
endif
|
||||
|
||||
call fzf#vim#ipc#stop()
|
||||
|
||||
let g:fzf_ipc = { 'fifo': tempname(), 'callback': a:Callback }
|
||||
if !filereadable(g:fzf_ipc.fifo)
|
||||
call system('mkfifo '..shellescape(g:fzf_ipc.fifo))
|
||||
if v:shell_error
|
||||
let fifo = tempname()
|
||||
call system('mkfifo '..shellescape(fifo))
|
||||
if v:shell_error
|
||||
if !exists('s:mkfifo_failed')
|
||||
let s:mkfifo_failed = 1
|
||||
call s:warn('Failed to create fifo')
|
||||
endif
|
||||
return ''
|
||||
endif
|
||||
|
||||
call fzf#vim#ipc#restart()
|
||||
let s:channels[fifo] = { 'fifo': fifo, 'callback': a:Callback }
|
||||
call fzf#vim#ipc#restart(fifo)
|
||||
if !s:running(s:channels[fifo].job)
|
||||
call fzf#vim#ipc#stop(fifo)
|
||||
return ''
|
||||
endif
|
||||
|
||||
return g:fzf_ipc.fifo
|
||||
return fifo
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#ipc#restart()
|
||||
if !exists('g:fzf_ipc')
|
||||
" Nvim hands over everything one read produced, which can be several messages
|
||||
" as well as the trailing empty element. Vim's out_cb passes one line at a
|
||||
" time, so deliver line by line and both behave the same.
|
||||
function! s:deliver(Callback, lines)
|
||||
for line in a:lines
|
||||
if !empty(line)
|
||||
call call(a:Callback, [line])
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" The reader is gone, so leaving the channel registered would block the next
|
||||
" write on a fifo nothing reads
|
||||
function! s:drop(fifo)
|
||||
if has_key(s:channels, a:fifo)
|
||||
call delete(remove(s:channels, a:fifo).fifo)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#ipc#restart(fifo)
|
||||
if !has_key(s:channels, a:fifo)
|
||||
throw 'fzf#vim#ipc not started'
|
||||
endif
|
||||
|
||||
let Callback = g:fzf_ipc.callback
|
||||
let chan = s:channels[a:fifo]
|
||||
let Callback = chan.callback
|
||||
let fifo = a:fifo
|
||||
if exists('*job_start')
|
||||
let g:fzf_ipc.job = job_start(
|
||||
\ ['cat', g:fzf_ipc.fifo],
|
||||
\ {'out_cb': { _, msg -> call(Callback, [msg]) },
|
||||
\ 'exit_cb': { _, status -> status == 0 ? fzf#vim#ipc#restart() : '' }}
|
||||
let chan.job = job_start(
|
||||
\ ['cat', fifo],
|
||||
\ {'out_cb': { _, msg -> has_key(s:channels, fifo) ? call(Callback, [msg]) : '' },
|
||||
\ 'exit_cb': { _, status -> status == 0 && has_key(s:channels, fifo) ? fzf#vim#ipc#restart(fifo) : s:drop(fifo) }}
|
||||
\ )
|
||||
else
|
||||
let eof = ['']
|
||||
let g:fzf_ipc.job = jobstart(
|
||||
\ ['cat', g:fzf_ipc.fifo],
|
||||
let chan.job = jobstart(
|
||||
\ ['cat', fifo],
|
||||
\ {'stdout_buffered': 1,
|
||||
\ 'on_stdout': { j, msg, e -> msg != eof ? call(Callback, msg) : '' },
|
||||
\ 'on_exit': { j, status, e -> status == 0 ? fzf#vim#ipc#restart() : '' }}
|
||||
\ 'on_stdout': { j, msg, e -> has_key(s:channels, fifo) ? s:deliver(Callback, msg) : '' },
|
||||
\ 'on_exit': { j, status, e -> status == 0 && has_key(s:channels, fifo) ? fzf#vim#ipc#restart(fifo) : s:drop(fifo) }}
|
||||
\ )
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#ipc#stop()
|
||||
if !exists('g:fzf_ipc')
|
||||
" Whether the job handle refers to a live job. Nvim returns -1 or 0 instead of
|
||||
" a handle when it cannot start one
|
||||
function! s:running(job)
|
||||
if exists('*job_status')
|
||||
return job_status(a:job) ==# 'run'
|
||||
endif
|
||||
return a:job > 0
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#ipc#stop(fifo)
|
||||
if !has_key(s:channels, a:fifo)
|
||||
return
|
||||
endif
|
||||
|
||||
let job = g:fzf_ipc.job
|
||||
if exists('*job_stop')
|
||||
call job_stop(job)
|
||||
else
|
||||
call jobstop(job)
|
||||
call jobwait([job])
|
||||
endif
|
||||
" Drop it first, so the exit handler does not restart the job
|
||||
let chan = remove(s:channels, a:fifo)
|
||||
" Never throw from here, this runs as part of fzf's exit handling
|
||||
try
|
||||
if exists('*job_stop')
|
||||
call job_stop(chan.job)
|
||||
else
|
||||
call jobstop(chan.job)
|
||||
call jobwait([chan.job])
|
||||
endif
|
||||
catch
|
||||
endtry
|
||||
|
||||
call delete(g:fzf_ipc.fifo)
|
||||
unlet g:fzf_ipc
|
||||
call delete(chan.fifo)
|
||||
endfunction
|
||||
|
||||
+46
-1
@@ -1,4 +1,4 @@
|
||||
fzf-vim.txt fzf-vim Last change: June 8 2025
|
||||
fzf-vim.txt fzf-vim Last change: May 31 2026
|
||||
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
|
||||
==============================================================================
|
||||
|
||||
@@ -150,6 +150,19 @@ COMMANDS *fzf-vim-commands*
|
||||
|
||||
- Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new
|
||||
tab, a new split, or in a new vertical split
|
||||
- Most commands support ALT-ENTER to insert the selected items into the
|
||||
current buffer instead of opening them. The inserted text depends on the
|
||||
command: file path (Files, GFiles, Buffers, History, Locate), line content
|
||||
(Lines, BLines, Marks, Changes), matched text (Rg, Ag, Grep), tag name
|
||||
(Tags, BTags), or commit hash (Commits, BCommits)
|
||||
- Most commands support CTRL-O to open the current entry in the window fzf
|
||||
was started from, leaving fzf open, so you can look through several
|
||||
entries in a single run (Files, GFiles, Buffers, History, Locate, Rg, Ag,
|
||||
Grep, Lines, BLines, Tags, BTags, Marks, Changes). Requires fzf 0.74.4 or
|
||||
later, and is not offered in fullscreen mode, with a layout that leaves no
|
||||
other window (enew, tabnew), on Windows, or when the key is already used
|
||||
by g:fzf_vim.paste_key, g:fzf_action, or the command itself, as
|
||||
CTRL-ALT-X is in :Buffers
|
||||
- Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen
|
||||
- You can set `g:fzf_vim.command_prefix` to give the same prefix to the commands
|
||||
- e.g. `let g:fzf_vim.command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
|
||||
@@ -224,6 +237,38 @@ behavior with `g:fzf_vim.preview_window`. Here are some examples:
|
||||
" let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'
|
||||
<
|
||||
|
||||
Paste key~
|
||||
*fzf-vim-paste-key*
|
||||
*g:fzf_vim.paste_key*
|
||||
|
||||
Most commands support a key to insert the selected items into the current
|
||||
buffer instead of opening them. Customize it with `g:fzf_vim.paste_key`.
|
||||
>
|
||||
" Key to insert the selected items into the current buffer
|
||||
" (default: 'alt-enter')
|
||||
let g:fzf_vim.paste_key = 'alt-enter'
|
||||
<
|
||||
|
||||
Show key~
|
||||
*fzf-vim-show-key*
|
||||
*g:fzf_vim.show_key*
|
||||
|
||||
Most commands support a key that opens the current entry in the window fzf was
|
||||
started from and leaves fzf open, so you can look through several entries in
|
||||
one run. It is labelled Show in the footer to set it apart from Enter, which
|
||||
opens the entry and closes fzf. Customize it with `g:fzf_vim.show_key`, or set
|
||||
it to an empty string to turn the key off. A comma-separated list binds every
|
||||
key in it. It takes the key over from `$FZF_DEFAULT_OPTS`, so pick another key
|
||||
or turn it off to keep a binding of your own.
|
||||
>
|
||||
" Key to open the current entry, leaving fzf open
|
||||
" (default: 'ctrl-o')
|
||||
let g:fzf_vim.show_key = 'ctrl-o'
|
||||
|
||||
" Use CTRL-O and double-click
|
||||
let g:fzf_vim.show_key = 'ctrl-o,double-click'
|
||||
<
|
||||
|
||||
Command-level options~
|
||||
*fzf-vim-command-level-options*
|
||||
|
||||
|
||||
+13
-7
@@ -98,14 +98,20 @@ if (has('nvim') || has('terminal') && has('patch-8.0.995')) && (s:conf('statusli
|
||||
if exists('#User#FzfStatusLine')
|
||||
doautocmd User FzfStatusLine
|
||||
else
|
||||
if $TERM !~ "256color"
|
||||
highlight default fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656
|
||||
highlight default fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656
|
||||
highlight default fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656
|
||||
" Do not display statusline when fzf is running in a floating window
|
||||
" (e.g. nvim-fzf)
|
||||
if has('nvim') && len(nvim_win_get_config(0).relative)
|
||||
return
|
||||
endif
|
||||
|
||||
if has('termguicolors') && &termguicolors || $TERM =~ "256color"
|
||||
highlight default fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656 gui=nocombine
|
||||
highlight default fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656 gui=nocombine
|
||||
highlight default fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656 gui=nocombine
|
||||
else
|
||||
highlight default fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656
|
||||
highlight default fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656
|
||||
highlight default fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656
|
||||
highlight default fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656 gui=nocombine
|
||||
highlight default fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656 gui=nocombine
|
||||
highlight default fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656 gui=nocombine
|
||||
endif
|
||||
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user