diff options
| author | elianiva <dicha.arkana03@gmail.com> | 2021-03-12 11:00:15 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-12 11:00:15 +0700 |
| commit | c8cc024ebf86d58dc37913e1e9ec7e465d687d68 (patch) | |
| tree | d8dc1e89b9d5d3e337621255b34c5d6576e5620c /lua/telescope/actions/init.lua | |
| parent | add7ee394350f268684cff03d844f32f255fec47 (diff) | |
feat: add `add_to_qflist`, `add_selected`, and `smart_add` (#636)
* feat: add `add_to_qflist`, `add_selected`, and `smart_add`
* refactor: use local function
Diffstat (limited to 'lua/telescope/actions/init.lua')
| -rw-r--r-- | lua/telescope/actions/init.lua | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 5741554..066600d 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -384,7 +384,7 @@ local entry_to_qf = function(entry) } end -actions.send_selected_to_qflist = function(prompt_bufnr) +local send_selected_to_qf = function(prompt_bufnr, mode) local picker = action_state.get_current_picker(prompt_bufnr) local qf_entries = {} @@ -394,10 +394,10 @@ actions.send_selected_to_qflist = function(prompt_bufnr) actions.close(prompt_bufnr) - vim.fn.setqflist(qf_entries, 'r') + vim.fn.setqflist(qf_entries, mode) end -actions.send_to_qflist = function(prompt_bufnr) +local send_all_to_qf = function(prompt_bufnr, mode) local picker = action_state.get_current_picker(prompt_bufnr) local manager = picker.manager @@ -408,18 +408,42 @@ actions.send_to_qflist = function(prompt_bufnr) actions.close(prompt_bufnr) - vim.fn.setqflist(qf_entries, 'r') + vim.fn.setqflist(qf_entries, mode) end -actions.smart_send_to_qflist = function(prompt_bufnr) +actions.send_selected_to_qflist = function(prompt_bufnr) + send_selected_to_qf(prompt_bufnr, 'r') +end + +actions.add_selected_to_qflist = function(prompt_bufnr) + send_selected_to_qf(prompt_bufnr, 'a') +end + +actions.send_to_qflist = function(prompt_bufnr) + send_all_to_qf(prompt_bufnr, 'r') +end + +actions.add_to_qflist = function(prompt_bufnr) + send_all_to_qf(prompt_bufnr, 'a') +end + +local smart_send = function(prompt_bufnr, mode) local picker = action_state.get_current_picker(prompt_bufnr) if table.getn(picker:get_multi_selection()) > 0 then - actions.send_selected_to_qflist(prompt_bufnr) + send_selected_to_qf(prompt_bufnr, mode) else - actions.send_to_qflist(prompt_bufnr) + send_all_to_qf(prompt_bufnr, mode) end end +actions.smart_send_to_qflist = function(prompt_bufnr) + smart_send(prompt_bufnr, 'r') +end + +actions.smart_add_to_qflist = function(prompt_bufnr) + smart_send(prompt_bufnr, 'a') +end + actions.complete_tag = function(prompt_bufnr) local current_picker = action_state.get_current_picker(prompt_bufnr) local tags = current_picker.sorter.tags |
