From fa69ad7b138dfb71ada504bf8fbc580216cde6b4 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Mon, 18 Apr 2022 09:52:08 -0700 Subject: [PATCH] lines|blines: added selection/multi-select to quickfix --- README.md | 14 ++++++++++---- doc/fzf-lua.txt | 14 ++++++++++---- lua/fzf-lua/actions.lua | 12 ++++++++++++ lua/fzf-lua/config.lua | 11 ++++++++++- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5b4fd26..9e1f04a 100644 --- a/README.md +++ b/README.md @@ -646,7 +646,11 @@ require'fzf-lua'.setup { ["--nth"] = '2..', ["--tiebreak"] = 'index', }, - -- actions inherit from 'actions.buffers' + -- actions inherit from 'actions.buffers' and merge + actions = { + ["default"] = { actions.buf_edit_or_qf }, + ["alt-q"] = { actions.buf_sel_to_qf } + }, }, blines = { previewer = "builtin", -- set to 'false' to disable @@ -658,10 +662,12 @@ require'fzf-lua'.setup { ['--delimiter'] = "'[\\]:]'", ["--with-nth"] = '2..', ["--tiebreak"] = 'index', - -- disable multi-select, set to false to disable - ["--no-multi"] = '', }, - -- actions inherit from 'actions.buffers' + -- actions inherit from 'actions.buffers' and merge + actions = { + ["default"] = { actions.buf_edit_or_qf }, + ["alt-q"] = { actions.buf_sel_to_qf } + }, }, tags = { prompt = 'Tags❯ ', diff --git a/doc/fzf-lua.txt b/doc/fzf-lua.txt index 5fcfa4d..26bacba 100644 --- a/doc/fzf-lua.txt +++ b/doc/fzf-lua.txt @@ -691,7 +691,11 @@ Consult the list below for available settings: ["--nth"] = '2..', ["--tiebreak"] = 'index', }, - -- actions inherit from 'actions.buffers' + -- actions inherit from 'actions.buffers' and merge + actions = { + ["default"] = { actions.buf_edit_or_qf }, + ["alt-q"] = { actions.buf_sel_to_qf } + }, }, blines = { previewer = "builtin", -- set to 'false' to disable @@ -703,10 +707,12 @@ Consult the list below for available settings: ['--delimiter'] = "'[\\]:]'", ["--with-nth"] = '2..', ["--tiebreak"] = 'index', - -- disable multi-select, set to false to disable - ["--no-multi"] = '', }, - -- actions inherit from 'actions.buffers' + -- actions inherit from 'actions.buffers' and merge + actions = { + ["default"] = { actions.buf_edit_or_qf }, + ["alt-q"] = { actions.buf_sel_to_qf } + }, }, tags = { prompt = 'Tags❯ ', diff --git a/lua/fzf-lua/actions.lua b/lua/fzf-lua/actions.lua index 17c0622..535bebb 100644 --- a/lua/fzf-lua/actions.lua +++ b/lua/fzf-lua/actions.lua @@ -281,6 +281,18 @@ M.buf_switch_or_edit = function(...) M.buf_edit(...) end +M.buf_sel_to_qf = function(selected, opts) + return M.file_sel_to_qf(selected, opts) +end + +M.buf_edit_or_qf = function(selected, opts) + if #selected>1 then + return M.buf_sel_to_qf(selected, opts) + else + return M.buf_edit(selected, opts) + end +end + M.colorscheme = function(selected) local colorscheme = selected[1] vim.cmd("colorscheme " .. colorscheme) diff --git a/lua/fzf-lua/config.lua b/lua/fzf-lua/config.lua index b942015..32ca32e 100644 --- a/lua/fzf-lua/config.lua +++ b/lua/fzf-lua/config.lua @@ -363,6 +363,10 @@ M.globals.lines = { ["--tiebreak"] = 'index', }, _actions = function() return M.globals.actions.buffers end, + actions = { + ["default"] = actions.buf_edit_or_qf, + ["alt-q"] = actions.buf_sel_to_qf + }, } M.globals.blines = { previewer = M._default_previewer_fn, @@ -375,9 +379,12 @@ M.globals.blines = { ['--delimiter'] = "'[:]'", ["--with-nth"] = '2..', ["--tiebreak"] = 'index', - ["--no-multi"] = '', }, _actions = function() return M.globals.actions.buffers end, + actions = { + ["default"] = actions.buf_edit_or_qf, + ["alt-q"] = actions.buf_sel_to_qf + }, } M.globals.tags = { previewer = { _ctor = previewers.builtin.tags }, @@ -828,6 +835,8 @@ M._action_to_helpstr = { [actions.file_switch] = "file-switch", [actions.file_switch_or_edit] = "file-switch-or-edit", [actions.buf_edit] = "buffer-edit", + [actions.buf_edit_or_qf] = "buffer-edit-or-qf", + [actions.buf_sel_to_qf] = "buffer-selection-to-qf", [actions.buf_split] = "buffer-split", [actions.buf_vsplit] = "buffer-vsplit", [actions.buf_tabedit] = "buffer-tabedit",