[mini.pick] Mapping delete not working on buffers picker #1752
-
Contributing guidelines
Module(s)mini.pick Question
atajo utilizado [ ] -en mi github tambien esta el codigo por si hay que tener alguna otra consideracion,bendecida noche y muchas gracias |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@Kogaraashi1 The issue occurs because when trying to delete a buffer with Additionally, as mentioned in Thus, the code should be modified as follows to achieve the expected behavior: Code (spoiler)local pick = require("mini.pick")
pick.registry.buffers = function(local_opts, opts)
local_opts = local_opts or {}
-- Delete the current buffer
local wipeout_cur = function()
vim.api.nvim_buf_delete(MiniPick.get_picker_matches().current.bufnr, {})
MiniPick.builtin.buffers(local_opts, opts)
end
-- Map <C-d> to delete the buffer
local buffer_mappings = { wipeout = { char = "<C-d>", func = wipeout_cur } }
-- Show buffers with short names
local show = function(buf_id, items, query)
vim.tbl_map(function(i) i.text = vim.fn.fnamemodify(i.text, ":t") end, items)
MiniPick.default_show(buf_id, items, query, { show_icons = true })
end
-- Merge options
opts = vim.tbl_deep_extend("force", {
source = { show = show },
mappings = buffer_mappings,
}, opts or {})
return MiniPick.builtin.buffers(local_opts, opts)
end With this modification, the buffer will be deleted correctly when |
Beta Was this translation helpful? Give feedback.
@Kogaraashi1 The issue occurs because when trying to delete a buffer with
<C-d>
, the list of buffers isn't updated as expected. This happens due to howmini.pick
is configured. According to the documentation formini.pick
, you can register a custom function to handle buffers, as explained inregistry
.Additionally, as mentioned in
buffers
, it's possible to map keys like<C-d>
to perform specific actions on buffers, such as deleting them.Thus, the code should be modified as follows to achieve the expected behavior:
Code (spoiler)