Skip to content
Myr

[vim] Make arguments to fzf#wrap() optional

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fzf#wrap([name string,] [opts dict,] [fullscreen boolean])

authored by Junegunn Choi · committed by Junegunn Choi · parent 37dc273 · Browse files · 2 files+17 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−10 removed

  • other:+17 added−10 removed

2 files+17 added−10 removed

modified:plugin/fzf.vim+16 added-9 removed
152 unmodified lines
153 silent! autocmd! fzf_swap154 endtry155endfunction156157" name string, [opts dict, [fullscreen boolean]]158function! fzf#wrap(name, ...)159 if type(a:name) != type('')160 throw 'invalid name type: string expected'161 endif162 let opts = copy(get(a:000, 0, {}))163 let bang = get(a:000, 1, 0)157" [name string,] [opts dict,] [fullscreen boolean]158function! fzf#wrap(...)159 let args = ['', {}, 0]160 let expects = map(copy(args), 'type(v:val)')161 let tidx = 0162 for arg in copy(a:000)163 let tidx = index(expects, type(arg), tidx)164 if tidx < 0165 throw 'invalid arguments (expected: [name string] [opts dict] [fullscreen boolean])'166 endif167 let args[tidx] = arg168 let tidx += 1169 endfor170 let [name, opts, bang] = args171172 " Layout: g:fzf_layout (and deprecated g:fzf_height)173 if bang174 for key in s:layout_keys
10 unmodified lines
185 endif186187 " History: g:fzf_history_dir188 let opts.options = get(opts, 'options', '')182 if len(get(g:, 'fzf_history_dir', ''))189 if len(name) && len(get(g:, 'fzf_history_dir', ''))190 let dir = expand(g:fzf_history_dir)191 if !isdirectory(dir)192 call mkdir(dir, 'p')193 endif187 let opts.options = join(['--history', s:escape(dir.'/'.a:name), opts.options])194 let opts.options = join(['--history', s:escape(dir.'/'.name), opts.options])195 endif196197 " Action: g:fzf_action198 if !s:has_any(opts, ['sink', 'sink*'])
365 unmodified lines
modified:README.md+1 added-1 removed
342 unmodified lines
343page](https://github.com/junegunn/fzf/wiki/Examples-(vim)).344345#### `fzf#wrap`346347`fzf#wrap(name string, [opts dict, [fullscreen boolean]])` is a helper347`fzf#wrap([name string,] [opts dict,] [fullscreen boolean])` is a helper348function that decorates the options dictionary so that it understands349`g:fzf_layout`, `g:fzf_action`, and `g:fzf_history_dir` like `:FZF`.350351```vim
73 unmodified lines