mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-08 05:24:47 +08:00
Append extra options string in completion functions
This commit is contained in:
@@ -778,6 +778,11 @@ function! fzf#vim#complete(...)
|
|||||||
endif
|
endif
|
||||||
let s:opts = s:eval(s:opts, 'source', s:query)
|
let s:opts = s:eval(s:opts, 'source', s:query)
|
||||||
let s:opts = s:eval(s:opts, 'options', s:query)
|
let s:opts = s:eval(s:opts, 'options', s:query)
|
||||||
|
let s:opts = s:eval(s:opts, 'extra_options', s:query)
|
||||||
|
if has_key(s:opts, 'extra_options')
|
||||||
|
let s:opts.options =
|
||||||
|
\ join(filter([get(s:opts, 'options', ''), remove(s:opts, 'extra_options')], '!empty(v:val)'))
|
||||||
|
endif
|
||||||
|
|
||||||
call feedkeys("\<Plug>(-fzf-complete-trigger)")
|
call feedkeys("\<Plug>(-fzf-complete-trigger)")
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
@@ -24,8 +24,18 @@
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
function! s:extend(base, extra)
|
||||||
|
let base = copy(a:base)
|
||||||
|
if has_key(a:extra, 'options')
|
||||||
|
let extra = copy(a:extra)
|
||||||
|
let extra.extra_options = remove(extra, 'options')
|
||||||
|
return extend(base, extra)
|
||||||
|
endif
|
||||||
|
return extend(base, a:extra)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! fzf#vim#complete#word(...)
|
function! fzf#vim#complete#word(...)
|
||||||
return fzf#vim#complete(extend({
|
return fzf#vim#complete(s:extend({
|
||||||
\ 'source': 'cat /usr/share/dict/words'},
|
\ 'source': 'cat /usr/share/dict/words'},
|
||||||
\ get(a:000, 0, g:fzf#vim#default_layout)))
|
\ get(a:000, 0, g:fzf#vim#default_layout)))
|
||||||
endfunction
|
endfunction
|
||||||
@@ -104,7 +114,7 @@ endfunction
|
|||||||
|
|
||||||
function! fzf#vim#complete#path(command, ...)
|
function! fzf#vim#complete#path(command, ...)
|
||||||
let s:file_cmd = a:command
|
let s:file_cmd = a:command
|
||||||
return fzf#vim#complete(extend({
|
return fzf#vim#complete(s:extend({
|
||||||
\ 'prefix': function('s:fname_prefix'),
|
\ 'prefix': function('s:fname_prefix'),
|
||||||
\ 'source': function('s:file_source'),
|
\ 'source': function('s:file_source'),
|
||||||
\ 'options': function('s:file_options')}, get(a:000, 0, g:fzf#vim#default_layout)))
|
\ 'options': function('s:file_options')}, get(a:000, 0, g:fzf#vim#default_layout)))
|
||||||
@@ -119,7 +129,7 @@ function! s:reduce_line(lines)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fzf#vim#complete#line(...)
|
function! fzf#vim#complete#line(...)
|
||||||
return fzf#vim#complete(extend({
|
return fzf#vim#complete(s:extend({
|
||||||
\ 'prefix': '^.*$',
|
\ 'prefix': '^.*$',
|
||||||
\ 'source': fzf#vim#_lines(0),
|
\ 'source': fzf#vim#_lines(0),
|
||||||
\ 'options': '--tiebreak=index --ansi --nth 3..',
|
\ 'options': '--tiebreak=index --ansi --nth 3..',
|
||||||
@@ -127,7 +137,7 @@ function! fzf#vim#complete#line(...)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fzf#vim#complete#buffer_line(...)
|
function! fzf#vim#complete#buffer_line(...)
|
||||||
call fzf#vim#complete(extend({
|
call fzf#vim#complete(s:extend({
|
||||||
\ 'prefix': '^.*$',
|
\ 'prefix': '^.*$',
|
||||||
\ 'source': s:uniq(getline(1, '$'))}, get(a:000, 0, g:fzf#vim#default_layout)))
|
\ 'source': s:uniq(getline(1, '$'))}, get(a:000, 0, g:fzf#vim#default_layout)))
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user