Skip to content
Snippets Groups Projects
Unverified Commit 2069bbc8 authored by Junegunn Choi's avatar Junegunn Choi
Browse files

[vim] Allow Funcref in g:fzf_action

parent 053d628b
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,19 @@ let g:fzf_action = {
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" An action can be a reference to a function that processes selected lines
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
......
fzf.txt fzf Last change: April 28 2017
fzf.txt fzf Last change: August 14 2017
FZF - TABLE OF CONTENTS *fzf* *fzf-toc*
==============================================================================
......@@ -80,6 +80,19 @@ Examples~
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" An action can be a reference to a function that processes selected lines
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
......
......@@ -201,7 +201,10 @@ function! s:common_sink(action, lines) abort
return
endif
let key = remove(a:lines, 0)
let cmd = get(a:action, key, 'e')
let Cmd = get(a:action, key, 'e')
if type(Cmd) == type(function('call'))
return Cmd(a:lines)
endif
if len(a:lines) > 1
augroup fzf_swap
autocmd SwapExists * let v:swapchoice='o'
......@@ -217,7 +220,7 @@ function! s:common_sink(action, lines) abort
execute 'e' s:escape(item)
let empty = 0
else
call s:open(cmd, item)
call s:open(Cmd, item)
endif
if !has('patch-8.0.0177') && !has('nvim-0.2') && exists('#BufEnter')
\ && isdirectory(item)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment