From e4c62dedd760d339bea5b8325c2d918d87476d00 Mon Sep 17 00:00:00 2001 From: Chen Lu Date: Sun, 26 Nov 2023 03:37:50 +0000 Subject: [PATCH] feat(actions): add delete_mark (#2769) * feat(actions): add delete_mark * style(init.lua): fix formatting --- doc/telescope.txt | 9 +++++++++ lua/telescope/actions/init.lua | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/doc/telescope.txt b/doc/telescope.txt index 898284e..dd35ada 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -3311,6 +3311,15 @@ actions.to_fuzzy_refine({prompt_bufnr}) *telescope.actions.to_fuzzy_refine()* {prompt_bufnr} (number) The prompt bufnr +actions.delete_mark({prompt_bufnr}) *telescope.actions.delete_mark()* + Delete the selected mark or all the marks selected using multi + selection. + + + Parameters: ~ + {prompt_bufnr} (number) The prompt bufnr + + ================================================================================ ACTIONS_STATE *telescope.actions.state* diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 442776d..3a2f5ee 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -1455,6 +1455,19 @@ actions.to_fuzzy_refine = function(prompt_bufnr) }) end +--- Delete the selected mark or all the marks selected using multi selection. +---@param prompt_bufnr number: The prompt bufnr +actions.delete_mark = function(prompt_bufnr) + local current_picker = action_state.get_current_picker(prompt_bufnr) + current_picker:delete_selection(function(selection) + local bufname = selection.filename + local bufnr = vim.fn.bufnr(bufname) + local mark = selection.ordinal:sub(1, 1) + local success = pcall(vim.api.nvim_buf_del_mark, bufnr, mark) + return success + end) +end + actions.nop = function(_) end -- ==================================================