[mini.visits] Ability to delete multiple registered paths via picker #1003
Replies: 2 comments 1 reply
-
Thanks for the idea and kind words about 'mini.visits'! Explicit index manipulation can be done in at least the following ways:
Indeed, applying a command to more than one item is not a part of
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Thanks very much Evgeni! I ended up with the following which enables deleting current and marked items using the default vim.keymap.set(
'n',
'<leader>vd',
function()
local picker = require('mini.pick')
local visits = require('mini.visits')
local remove_paths = function(items)
for _, v in ipairs(items) do
visits.remove_path(v)
end
picker.set_picker_items(visits.list_paths())
return true
end
picker.setup({
source = {
items = visits.list_paths(),
choose = function(item) return remove_paths({ item }) end,
choose_marked = remove_paths,
}
})
picker.start()
end,
{ desc = '[V]isits [d]elete paths' }
) |
Beta Was this translation helpful? Give feedback.
-
First, thank you for writing such a great plugin. It has been smooth sailing integrating and using it every day.
There's one part of my workflow that I haven't figured out with the default features/examples and I'm open to either making something or changing my workflow.
The feature is deleting multiple registered paths using a picker of some sort.
My workflow (harpoon-bred)
track = { event = '' }
MiniVisits.register_visit()
MiniVisits.iterate_paths("forward", nil, { wrap = true })
(forward/backward)MiniVisits.remove_path()
Hiccup
In Step 7 above, I need to visit each file I want to remove/unregister and then remove it.
It would be great if I could delete multiple in one go.
Harpoon feature
A custom picker can be opened which supports vim actions
dd, p, etc
to edit/reorder saved paths.I would often
dd
in the single picker multiple times when finished with multiple files.vim.ui.select
I see it's possible to customize the action that
vim.ui.select()
does and have used it below.This enables deleting a single path via a picker, but I'm not sure how to delete multiple here.
telescope.nvim
This seems to support multiple selections with the default-mappings
Tab
.I tried using https://github.com/nvim-telescope/telescope-ui-select.nvim as the picker and can use
Tab
to "mark" multiple paths.However I can't see how multiple "marked paths" can be passed to the function, it seems to pass only what I hit
<CR>
on, which makes sense as the function definition isvim.ui.select(fn, {}, <single_choice>)
.I've come across a potential telescope based solution which I could change the action from opening file to deleting path: nvim-telescope/telescope.nvim#1048 (comment)
mini.pick
Is there something in https://github.com/echasnovski/mini.pick that would work?
How would I apply a command to all "marked" items?
Beta Was this translation helpful? Give feedback.
All reactions