From 7d364f8be7826e2cdd3a09d6c1f9d7a92b1ec5d5 Mon Sep 17 00:00:00 2001 From: Brian Ryall Date: Mon, 22 Nov 2021 12:24:51 -0500 Subject: [PATCH] add telescope mark delete --- lua/telescope/_extensions/marks.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lua/telescope/_extensions/marks.lua b/lua/telescope/_extensions/marks.lua index 4afaaa2..d9e1ea8 100644 --- a/lua/telescope/_extensions/marks.lua +++ b/lua/telescope/_extensions/marks.lua @@ -1,10 +1,23 @@ +local action_state = require("telescope.actions.state") +local entry_display = require("telescope.pickers.entry_display") local finders = require("telescope.finders") -local make_entry = require("telescope.make_entry") local pickers = require("telescope.pickers") local previewers = require("telescope.previewers") local sorters = require("telescope.sorters") local harpoon = require("harpoon") -local entry_display = require("telescope.pickers.entry_display") +local harpoon_mark = require("harpoon.mark") + +local delete_harpoon_mark = function(prompt_bufnr) + local confirmation = vim.fn.input(string.format("Delete current mark? [y/n]: ")) + if string.len(confirmation) == 0 or string.sub(string.lower(confirmation), 0, 1) ~= "y" then + print(string.format("Didn't delete mark")) + return + end + local current_picker = action_state.get_current_picker(prompt_bufnr) + current_picker:delete_selection(function(selection) + harpoon_mark.rm_file(selection.filename) + end) +end return function(opts) opts = opts or {} @@ -41,5 +54,10 @@ return function(opts) }), sorter = sorters.get_fuzzy_file(), previewer = previewers.vim_buffer_cat.new({}), + attach_mappings = function(_, map) + map("i", "", delete_harpoon_mark) + map("n", "", delete_harpoon_mark) + return true + end, }):find() end