Last active
April 27, 2024 12:21
-
-
Save benlubas/09254459af633cce1b5ac12d16640f0e to your computer and use it in GitHub Desktop.
Harpoon mark files from telescope picker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
M = {} | |
local telescope_utils = require("telescope.actions.utils") | |
local utils = require("telescope.actions.utils") | |
local actions = require("telescope.actions") | |
M.mark_file = function(tb) | |
actions.drop_all(tb) | |
actions.add_selection(tb) | |
telescope_utils.map_selections(tb, function(selection) | |
local file = selection[1] | |
-- This lets it work with live grep picker | |
if selection.filename then | |
file = selection.filename | |
end | |
-- this lets it work with git status picker | |
if selection.value then | |
file = selection.filename | |
end | |
pcall(require("harpoon.mark").add_file, file) | |
end) | |
actions.remove_selection(tb) | |
end | |
return M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nah,
Its working fine. Thank you!