feat: send to loclist (#868)
This commit is contained in:
@@ -313,6 +313,28 @@ actions.add_to_qflist() *actions.add_to_qflist()*
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actions.send_selected_to_loclist() *actions.send_selected_to_loclist()*
|
||||||
|
Sends the selected entries to the location list, replacing the previous
|
||||||
|
entries.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actions.add_selected_to_loclist() *actions.add_selected_to_loclist()*
|
||||||
|
Adds the selected entries to the location list, keeping the previous
|
||||||
|
entries.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actions.send_to_loclist() *actions.send_to_loclist()*
|
||||||
|
Sends all entries to the location list, replacing the previous entries.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actions.add_to_loclist() *actions.add_to_loclist()*
|
||||||
|
Adds all entries to the location list, keeping the previous entries.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
actions.smart_send_to_qflist() *actions.smart_send_to_qflist()*
|
actions.smart_send_to_qflist() *actions.smart_send_to_qflist()*
|
||||||
Sends the selected entries to the quickfix list, replacing the previous
|
Sends the selected entries to the quickfix list, replacing the previous
|
||||||
entries. If no entry was selected, sends all entries.
|
entries. If no entry was selected, sends all entries.
|
||||||
@@ -325,11 +347,28 @@ actions.smart_add_to_qflist() *actions.smart_add_to_qflist()*
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actions.smart_send_to_loclist() *actions.smart_send_to_loclist()*
|
||||||
|
Sends the selected entries to the location list, replacing the previous
|
||||||
|
entries. If no entry was selected, sends all entries.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actions.smart_add_to_loclist() *actions.smart_add_to_loclist()*
|
||||||
|
Adds the selected entries to the location list, keeping the previous
|
||||||
|
entries. If no entry was selected, adds all entries.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
actions.open_qflist() *actions.open_qflist()*
|
actions.open_qflist() *actions.open_qflist()*
|
||||||
Open the quickfix list
|
Open the quickfix list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actions.open_loclist() *actions.open_loclist()*
|
||||||
|
Open the location list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
*telescope.builtin*
|
*telescope.builtin*
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ local entry_to_qf = function(entry)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local send_selected_to_qf = function(prompt_bufnr, mode)
|
local send_selected_to_qf = function(prompt_bufnr, mode, target)
|
||||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
|
|
||||||
local qf_entries = {}
|
local qf_entries = {}
|
||||||
@@ -499,10 +499,14 @@ local send_selected_to_qf = function(prompt_bufnr, mode)
|
|||||||
|
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
|
|
||||||
vim.fn.setqflist(qf_entries, mode)
|
if target == 'loclist' then
|
||||||
|
vim.fn.setloclist(picker.original_win_id, qf_entries, mode)
|
||||||
|
else
|
||||||
|
vim.fn.setqflist(qf_entries, mode)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local send_all_to_qf = function(prompt_bufnr, mode)
|
local send_all_to_qf = function(prompt_bufnr, mode, target)
|
||||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
local manager = picker.manager
|
local manager = picker.manager
|
||||||
|
|
||||||
@@ -513,7 +517,11 @@ local send_all_to_qf = function(prompt_bufnr, mode)
|
|||||||
|
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
|
|
||||||
vim.fn.setqflist(qf_entries, mode)
|
if target == 'loclist' then
|
||||||
|
vim.fn.setloclist(picker.original_win_id, qf_entries, mode)
|
||||||
|
else
|
||||||
|
vim.fn.setqflist(qf_entries, mode)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
||||||
@@ -536,12 +544,32 @@ actions.add_to_qflist = function(prompt_bufnr)
|
|||||||
send_all_to_qf(prompt_bufnr, 'a')
|
send_all_to_qf(prompt_bufnr, 'a')
|
||||||
end
|
end
|
||||||
|
|
||||||
local smart_send = function(prompt_bufnr, mode)
|
--- Sends the selected entries to the location list, replacing the previous entries.
|
||||||
|
actions.send_selected_to_loclist = function(prompt_bufnr)
|
||||||
|
send_selected_to_qf(prompt_bufnr, 'r', 'loclist')
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Adds the selected entries to the location list, keeping the previous entries.
|
||||||
|
actions.add_selected_to_loclist = function(prompt_bufnr)
|
||||||
|
send_selected_to_qf(prompt_bufnr, 'a', 'loclist')
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Sends all entries to the location list, replacing the previous entries.
|
||||||
|
actions.send_to_loclist = function(prompt_bufnr)
|
||||||
|
send_all_to_qf(prompt_bufnr, 'r', 'loclist')
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Adds all entries to the location list, keeping the previous entries.
|
||||||
|
actions.add_to_loclist = function(prompt_bufnr)
|
||||||
|
send_all_to_qf(prompt_bufnr, 'a', 'loclist')
|
||||||
|
end
|
||||||
|
|
||||||
|
local smart_send = function(prompt_bufnr, mode, target)
|
||||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
if table.getn(picker:get_multi_selection()) > 0 then
|
if table.getn(picker:get_multi_selection()) > 0 then
|
||||||
send_selected_to_qf(prompt_bufnr, mode)
|
send_selected_to_qf(prompt_bufnr, mode, target)
|
||||||
else
|
else
|
||||||
send_all_to_qf(prompt_bufnr, mode)
|
send_all_to_qf(prompt_bufnr, mode, target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -557,6 +585,18 @@ actions.smart_add_to_qflist = function(prompt_bufnr)
|
|||||||
smart_send(prompt_bufnr, 'a')
|
smart_send(prompt_bufnr, 'a')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sends the selected entries to the location list, replacing the previous entries.
|
||||||
|
--- If no entry was selected, sends all entries.
|
||||||
|
actions.smart_send_to_loclist = function(prompt_bufnr)
|
||||||
|
smart_send(prompt_bufnr, 'r', 'loclist')
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Adds the selected entries to the location list, keeping the previous entries.
|
||||||
|
--- If no entry was selected, adds all entries.
|
||||||
|
actions.smart_add_to_loclist = function(prompt_bufnr)
|
||||||
|
smart_send(prompt_bufnr, 'a', 'loclist')
|
||||||
|
end
|
||||||
|
|
||||||
actions.complete_tag = function(prompt_bufnr)
|
actions.complete_tag = function(prompt_bufnr)
|
||||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
local tags = current_picker.sorter.tags
|
local tags = current_picker.sorter.tags
|
||||||
@@ -605,6 +645,11 @@ actions.open_qflist = function(_)
|
|||||||
vim.cmd [[copen]]
|
vim.cmd [[copen]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Open the location list
|
||||||
|
actions.open_loclist = function(_)
|
||||||
|
vim.cmd [[lopen]]
|
||||||
|
end
|
||||||
|
|
||||||
-- ==================================================
|
-- ==================================================
|
||||||
-- Transforms modules and sets the corect metatables.
|
-- Transforms modules and sets the corect metatables.
|
||||||
-- ==================================================
|
-- ==================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user