From 8783bea06e1e0dfa8dfd4834058923088471d832 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Mon, 11 Jan 2021 13:29:37 -0500 Subject: feat: quickfix (#293) * feat: quickfix (not implemented) * [WIP]: Wed 09 Dec 2020 11:11:30 PM EST * somewhat working linked list impl * getting closer * might be working * might be working for real * works and implemented basic example * dont forget to close prompt * fix descending and add more tests * test fixes * fix test * more logging * Fix some more tests * Fix logging messing up tests * fix: lint * fix: multi select stuffs --- lua/telescope/actions/init.lua | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'lua/telescope/actions/init.lua') diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 6ffb3ef..f4c3b08 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -38,6 +38,16 @@ function actions.add_selection(prompt_bufnr) current_picker:add_selection(current_picker:get_selection_row()) end +function actions.remove_selection(prompt_bufnr) + local current_picker = actions.get_current_picker(prompt_bufnr) + current_picker:remove_selection(current_picker:get_selection_row()) +end + +function actions.toggle_selection(prompt_bufnr) + local current_picker = actions.get_current_picker(prompt_bufnr) + current_picker:toggle_selection(current_picker:get_selection_row()) +end + --- Get the current entry function actions.get_selected_entry() return state.get_global_key('selected_entry') @@ -273,6 +283,45 @@ actions.git_staging_toggle = function(prompt_bufnr) require('telescope.builtin').git_status() end +local entry_to_qf = function(entry) + return { + bufnr = entry.bufnr, + filename = entry.filename, + lnum = entry.lnum, + col = entry.col, + text = entry.value, + } +end + +actions.send_selected_to_qflist = function(prompt_bufnr) + local picker = actions.get_current_picker(prompt_bufnr) + + local qf_entries = {} + for entry in pairs(picker.multi_select) do + table.insert(qf_entries, entry_to_qf(entry)) + end + + actions.close(prompt_bufnr) + + vim.fn.setqflist(qf_entries, 'r') + vim.cmd [[copen]] +end + +actions.send_to_qflist = function(prompt_bufnr) + local picker = actions.get_current_picker(prompt_bufnr) + local manager = picker.manager + + local qf_entries = {} + for entry in manager:iter() do + table.insert(qf_entries, entry_to_qf(entry)) + end + + actions.close(prompt_bufnr) + + vim.fn.setqflist(qf_entries, 'r') + vim.cmd [[copen]] +end + -- ================================================== -- Transforms modules and sets the corect metatables. -- ================================================== -- cgit v1.2.3