Skip to content

Commit a74731d

Browse files
committed
[vim] Add 'sinklist' as a synonym to 'sink*'
So that it's easier to add a sinklist function to a spec dictionary. let spec = { 'source': source, 'options': ['--preview', preview] } function spec.sinklist(matches) echom string(a:matches) endfunction call fzf#run(fzf#wrap(spec))
1 parent e086f0b commit a74731d

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README-VIM.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ The following table summarizes the available options.
283283
| `source` | list | Vim list as input to fzf |
284284
| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |
285285
| `sink` | funcref | Reference to function to process each selected item |
286-
| `sink*` | funcref | Similar to `sink`, but takes the list of output lines at once |
286+
| `sinklist` (or `sink*`) | funcref | Similar to `sink`, but takes the list of output lines at once |
287287
| `options` | string/list | Options to fzf |
288288
| `dir` | string | Working directory |
289289
| `up`/`down`/`left`/`right` | number/string | (Layout) Window position and size (e.g. `20`, `50%`) |
@@ -387,7 +387,7 @@ command! -bang -complete=dir -nargs=? LS
387387

388388
- `g:fzf_layout`
389389
- `g:fzf_action`
390-
- **Works only when no custom `sink` (or `sink*`) is provided**
390+
- **Works only when no custom `sink` (or `sinklist`) is provided**
391391
- Having custom sink usually means that each entry is not an ordinary
392392
file path (e.g. name of color scheme), so we can't blindly apply the
393393
same strategy (i.e. `tabedit some-color-scheme` doesn't make sense)

doc/fzf.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ The following table summarizes the available options.
300300
`source` | list | Vim list as input to fzf
301301
`sink` | string | Vim command to handle the selected item (e.g. `e` , `tabe` )
302302
`sink` | funcref | Reference to function to process each selected item
303-
`sink*` | funcref | Similar to `sink` , but takes the list of output lines at once
303+
`sinklist` (or `sink*` ) | funcref | Similar to `sink` , but takes the list of output lines at once
304304
`options` | string/list | Options to fzf
305305
`dir` | string | Working directory
306306
`up` / `down` / `left` / `right` | number/string | (Layout) Window position and size (e.g. `20` , `50%` )

plugin/fzf.vim

+5-3
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,13 @@ function! fzf#wrap(...)
419419
endif
420420

421421
" Action: g:fzf_action
422-
if !s:has_any(opts, ['sink', 'sink*'])
422+
if !s:has_any(opts, ['sink', 'sinklist', 'sink*'])
423423
let opts._action = get(g:, 'fzf_action', s:default_action)
424424
let opts.options .= ' --expect='.join(keys(opts._action), ',')
425-
function! opts.sink(lines) abort
425+
function! opts.sinklist(lines) abort
426426
return s:common_sink(self._action, a:lines)
427427
endfunction
428-
let opts['sink*'] = remove(opts, 'sink')
428+
let opts['sink*'] = opts.sinklist " For backward compatibility
429429
endif
430430

431431
return opts
@@ -943,6 +943,8 @@ function! s:callback(dict, lines) abort
943943
endif
944944
if has_key(a:dict, 'sink*')
945945
call a:dict['sink*'](a:lines)
946+
elseif has_key(a:dict, 'sinklist')
947+
call a:dict['sinklist'](a:lines)
946948
endif
947949
catch
948950
if stridx(v:exception, ':E325:') < 0

0 commit comments

Comments
 (0)