-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: send a subset of files to the quickfixlist #522
Comments
Here is another version (that breaks the prior behavior) which adds the files that match the latest search pattern: local function searched_oil_files_to_quickfix()
if vim.bo.filetype ~= "oil" then
return
end
local pattern = vim.fn.getreg("/")
if pattern == "" then
return
end
local oil = require("oil")
local dir = oil.get_current_dir()
local entries = {}
for line_number = 1, vim.fn.line("$") do
local entry = oil.get_entry_on_line(0, line_number)
if entry and entry.name:find(pattern) and entry.type == "file" then
table.insert(entries, { filename = dir .. entry.name })
end
end
if #entries == 0 then
return
end
vim.fn.setqflist(entries)
return vim.cmd.copen()
end |
Sorry for spamming. But I figured out a way to keep the original behavior and combining my two suggestions. The following code adds all files that are 1. matched if highlighting of matched items is active else all files and 2. are visually selected if you are in any visual mode else all files in directory local function selected_oil_files_to_quickfix()
if vim.bo.filetype ~= "oil" then
return
end
local oil = require("oil")
local dir = oil.get_current_dir()
local start_line = 1
local end_line = vim.fn.line("$")
local mode = vim.fn.mode()
if mode == "v" or mode == "V" or mode == "\22" then
start_line = vim.fn.line("v")
end_line = vim.fn.line(".")
if start_line > end_line then
start_line, end_line = end_line, start_line
end
end
local pattern = vim.fn.getreg("/")
local entries = {}
for line_number = start_line, end_line do
local entry = oil.get_entry_on_line(0, line_number)
if
entry
and entry.type == "file"
and (vim.v.hlsearch == 0 or (vim.v.hlsearch == 1 and entry.name:find(pattern)))
then
table.insert(entries, { filename = dir .. entry.name })
end
end
if #entries == 0 then
return
end
vim.fn.setqflist(entries)
return vim.cmd.copen()
end |
I would review a PR along these lines. I think it makes sense to transparently take just the selected rows when in visual mode, but I don't think it's intuitive to take search matches when search highlighting is active. For that, I'd want to either make a new action or add an option to this action that is off by default. |
Yeah I can understand that. I just thought it would be nice to have the
ability to search for files to add, but there are probably better ways to
do that
…On Tue, 3 Dec 2024, 03:17 Steven Arcangeli, ***@***.***> wrote:
I would review a PR along these lines. I think it makes sense to
transparently take just the selected rows when in visual mode, but I don't
think it's intuitive to take search matches when search highlighting is
active. For that, I'd want to either make a new action or add an option to
this action that is off by default.
—
Reply to this email directly, view it on GitHub
<#522 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQHJTETAXL5UWD7OSMHKWGD2DUIC3AVCNFSM6AAAAABSU35AA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJTGM4TGNZSGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
To be clear, I think that is a fine feature I just think it is an unintuitive default |
I was going through the code and noticed that adding only the highlighted files is already an option through "actions.send_to_qflist". However, that action is not very easy to find in the documentation. Also, a detail is that my implementation automatically opens the quickfix list which I think is nice |
Did you check existing requests?
Describe the feature
The ability to send all files in a directory to the quickfixlist was recently added (#223). An obvious extension would be to only send some of the selected files, either only the visually selected files, or something more clever
Provide background
Example: You would like to do some quickfix-edit to some files in a directory, but there are also a lot of files that you do not want to edit. I want a good way to add only some of the files
What is the significance of this feature?
nice to have
Additional details
I have adapted the code mentioned above to work for visually selected lines (without breaking the prior behavior):
The text was updated successfully, but these errors were encountered: