[Harpoon 2] Feature Request: Load all buffers in scope into harpoon
Opened this issue · 0 comments
What issue are you having that you need harpoon to solve?
Scenario: The user starts working on a project & has a few buffers open. The user then realizes that they need to add all these open files to harpoon. The user needs to manually navigate to each buffer & add it to harpoon manually.
Why doesn't the current config help?
My initial investigation did not show me a way to bulk add all current buffers into harpoon.
What proposed api changes are you suggesting?
I have a bare minimum implementation that can be added to lua/harpoon/mark.lua
.
I am not familiar with the testing/CI setup for harpoon, so I am adding the code here.
If anybody else is interested in having this feature, feel free to open a proper PR with the following code:
function M.harpoon_buffers()
for _, buffer_index in ipairs(vim.api.nvim_list_bufs()) do
local buffer_name = vim.api.nvim_buf_get_name(buffer_number)
if buffer_name ~= '' then
M.add_file(buffer_name)
end
end
end
Caveats & Additional Suggestions
- Avoid adding harpoon ui buffers into harpoon
- The function could accept an optional parameter like "*.lua" to add only buffers holding files of a specific type.