add telescope mark delete

This commit is contained in:
Brian Ryall 2021-11-22 12:24:51 -05:00
parent 0a367e1f4a
commit 7d364f8be7

View File

@ -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", "<c-d>", delete_harpoon_mark)
map("n", "<c-d>", delete_harpoon_mark)
return true
end,
}):find()
end