diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2021-01-11 13:29:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-11 13:29:37 -0500 |
| commit | 8783bea06e1e0dfa8dfd4834058923088471d832 (patch) | |
| tree | 050096ba649a94bb01e7c0b3a029e9b4eb060029 /lua/telescope/actions/init.lua | |
| parent | de80a9837cd1d207981c1f6dbf504436f8bfee13 (diff) | |
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
Diffstat (limited to 'lua/telescope/actions/init.lua')
| -rw-r--r-- | lua/telescope/actions/init.lua | 49 |
1 files changed, 49 insertions, 0 deletions
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. -- ================================================== |
