diff --git a/README.md b/README.md index afbffa8..3dfb677 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,7 @@ following exceptions: - Or a function to extract completion prefix - Both `source` and `options` can be given as funcrefs that take the completion prefix as the argument and return the final value -- `sink` or `sink*` are not allowed +- `sink` or `sink*` are ignored #### Reducer example diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index ac6460b..4463802 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -82,11 +82,6 @@ function! fzf#vim#wrap(opts) return fzf#wrap(a:opts) endfunction -" Deprecated -function! fzf#vim#layout(...) - return (a:0 && a:1) ? {} : copy(get(g:, 'fzf_layout', g:fzf#vim#default_layout)) -endfunction - function! s:wrap(name, opts, bang) " fzf#wrap does not append --expect if sink or sink* is found let opts = copy(a:opts) @@ -1164,16 +1159,20 @@ endfunction function! fzf#vim#complete(...) if a:0 == 0 - let s:opts = g:fzf#vim#default_layout + let s:opts = fzf#wrap() elseif type(a:1) == s:TYPE.dict - if has_key(a:1, 'sink') || has_key(a:1, 'sink*') - echoerr 'sink not allowed' - return '' - endif let s:opts = copy(a:1) + elseif type(a:1) == s:TYPE.string + let s:opts = extend({'source': a:1}, get(a:000, 1, fzf#wrap())) else - let s:opts = extend({'source': a:1}, g:fzf#vim#default_layout) + echoerr 'Invalid argument: '.string(a:000) + return '' endif + for s in ['sink', 'sink*'] + if has_key(s:opts, s) + call remove(s:opts, s) + endif + endfor let eol = col('$') let ve = &ve @@ -1199,6 +1198,10 @@ function! fzf#vim#complete(...) let s:opts.options = \ join(filter([get(s:opts, 'options', ''), remove(s:opts, 'extra_options')], '!empty(v:val)')) endif + if has_key(s:opts, 'options') + " FIXME: fzf currently doesn't have --no-expect option + let s:opts.options = substitute(s:opts.options, '--expect=[^ ]*', '', 'g') + endif call feedkeys("\(-fzf-complete-trigger)") return '' diff --git a/autoload/fzf/vim/complete.vim b/autoload/fzf/vim/complete.vim index 62eb50e..2a0c2b6 100644 --- a/autoload/fzf/vim/complete.vim +++ b/autoload/fzf/vim/complete.vim @@ -48,7 +48,7 @@ endif function! fzf#vim#complete#word(...) return fzf#vim#complete(s:extend({ \ 'source': 'cat /usr/share/dict/words'}, - \ get(a:000, 0, g:fzf#vim#default_layout))) + \ get(a:000, 0, fzf#wrap()))) endfunction " ---------------------------------------------------------------------------- @@ -128,7 +128,7 @@ function! fzf#vim#complete#path(command, ...) return fzf#vim#complete(s:extend({ \ 'prefix': s:function('s:fname_prefix'), \ 'source': s:function('s:file_source'), - \ 'options': s:function('s:file_options')}, get(a:000, 0, g:fzf#vim#default_layout))) + \ 'options': s:function('s:file_options')}, get(a:000, 0, fzf#wrap()))) endfunction " ---------------------------------------------------------------------------- @@ -147,13 +147,13 @@ function! fzf#vim#complete#line(...) \ 'prefix': '^.*$', \ 'source': lines, \ 'options': '--tiebreak=index --ansi --nth '.nth.'.. --tabstop=1', - \ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, g:fzf#vim#default_layout))) + \ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, fzf#wrap()))) endfunction function! fzf#vim#complete#buffer_line(...) return fzf#vim#complete(s:extend({ \ 'prefix': '^.*$', - \ 'source': fzf#vim#_uniq(getline(1, '$'))}, get(a:000, 0, g:fzf#vim#default_layout))) + \ 'source': fzf#vim#_uniq(getline(1, '$'))}, get(a:000, 0, fzf#wrap()))) endfunction let &cpo = s:cpo_save diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt index 235ec28..0a99c49 100644 --- a/doc/fzf-vim.txt +++ b/doc/fzf-vim.txt @@ -274,7 +274,7 @@ following exceptions: - Or a function to extract completion prefix - Both `source` and `options` can be given as funcrefs that take the completion prefix as the argument and return the final value - - `sink` or `sink*` are not allowed + - `sink` or `sink*` are ignored Reducer example~ diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 8325956..a1281bc 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -24,8 +24,6 @@ let s:cpo_save = &cpo set cpo&vim -let g:fzf#vim#default_layout = {'down': '~40%'} - function! s:defs(commands) let prefix = get(g:, 'fzf_command_prefix', '') if prefix =~# '^[^A-Z]'