mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
feat(picker.marks): added <c-x> to delete a mark from the list. See #2390
This commit is contained in:
parent
20ac8bfc4a
commit
9a04605664
3 changed files with 26 additions and 3 deletions
|
|
@ -337,6 +337,20 @@ function M.bufdelete(picker)
|
|||
picker:refresh()
|
||||
end
|
||||
|
||||
function M.mark_delete(picker)
|
||||
local selected = picker:selected({ fallback = true })
|
||||
for _, item in ipairs(selected) do
|
||||
if item.label then
|
||||
if item.buf then
|
||||
vim.api.nvim_buf_del_mark(item.buf, item.label)
|
||||
else
|
||||
vim.api.nvim_del_mark(item.label)
|
||||
end
|
||||
end
|
||||
end
|
||||
picker:refresh()
|
||||
end
|
||||
|
||||
function M.git_stage(picker)
|
||||
local items = picker:selected({ fallback = true })
|
||||
local first = items[1]
|
||||
|
|
|
|||
|
|
@ -807,6 +807,13 @@ M.marks = {
|
|||
format = "file",
|
||||
global = true,
|
||||
["local"] = true,
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<c-x>"] = { "mark_delete", mode = { "n", "i" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
---@class snacks.picker.notifications.Config: snacks.picker.Config
|
||||
|
|
|
|||
|
|
@ -58,18 +58,20 @@ function M.history(opts)
|
|||
end
|
||||
|
||||
---@param opts snacks.picker.marks.Config
|
||||
function M.marks(opts)
|
||||
---@type snacks.picker.finder
|
||||
function M.marks(opts, ctx)
|
||||
local marks = {} ---@type vim.fn.getmarklist.ret.item[]
|
||||
local current_buf = ctx.filter.current_buf
|
||||
if opts.global then
|
||||
vim.list_extend(marks, vim.fn.getmarklist())
|
||||
end
|
||||
if opts["local"] then
|
||||
vim.list_extend(marks, vim.fn.getmarklist(vim.api.nvim_get_current_buf()))
|
||||
vim.list_extend(marks, vim.fn.getmarklist(current_buf))
|
||||
end
|
||||
|
||||
---@type snacks.picker.finder.Item[]
|
||||
local items = {}
|
||||
local bufname = vim.api.nvim_buf_get_name(0)
|
||||
local bufname = vim.api.nvim_buf_get_name(current_buf)
|
||||
for _, mark in ipairs(marks) do
|
||||
local file = mark.file or bufname
|
||||
local buf = mark.pos[1] and mark.pos[1] > 0 and mark.pos[1] or nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue