-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Harpoon2] Remove files from list when using telescope picker (and possibly also reorder them..?) #499
Comments
I believe this already exists, as can be seen in return function(opts)
opts = opts or {}
pickers
.new(opts, {
prompt_title = "harpoon marks",
finder = generate_new_finder(),
sorter = conf.generic_sorter(opts),
previewer = conf.grep_previewer(opts),
attach_mappings = function(_, map)
map("i", "<c-d>", delete_harpoon_mark)
map("n", "<c-d>", delete_harpoon_mark)
map("i", "<c-p>", move_mark_up)
map("n", "<c-p>", move_mark_up)
map("i", "<c-n>", move_mark_down)
map("n", "<c-n>", move_mark_down)
return true
end,
})
:find()
end |
I mean, not really. local harpoon = require('harpoon')
harpoon:setup({})
-- basic telescope configuration
local conf = require("telescope.config").values
local function toggle_telescope(harpoon_files)
local file_paths = {}
for _, item in ipairs(harpoon_files.items) do
table.insert(file_paths, item.value)
end
require("telescope.pickers").new({}, {
prompt_title = "Harpoon",
finder = require("telescope.finders").new_table({
results = file_paths,
}),
previewer = conf.file_previewer({}),
sorter = conf.generic_sorter({}),
}):find()
end
vim.keymap.set("n", "<C-e>", function() toggle_telescope(harpoon:list()) end,
{ desc = "Open harpoon window" }) I tried the telescope extension you suggested and it works, providing most of the functionality I requested, but then, why is the code above mentioned in the README section for Telescope? |
I don't think that there's a difference, in your context!?
I think it's just meant as an example, not a solution!? You could try out PR #512! Maybe it behaves a little more as you'd expect?! It sounds like, it does everything that you mentioned here!? Also, you can use |
Marks in lualine, custom mapping to delete marks in Telescope Also see ThePrimeagen/harpoon#512 and ThePrimeagen/harpoon#499
Marks in lualine, custom mapping to delete marks in Telescope Also see ThePrimeagen/harpoon#512 and ThePrimeagen/harpoon#499
This should work local function toggle_telescope(harpoon_files)
local finder = function()
local paths = {}
for _, item in ipairs(harpoon_files.items) do
table.insert(paths, item.value)
end
return require("telescope.finders").new_table({
results = paths,
})
end
require("telescope.pickers").new({}, {
prompt_title = "Harpoon",
finder = finder(),
previewer = false,
sorter = require("telescope.config").values.generic_sorter({}),
layout_config = {
height = 0.4,
width = 0.5,
prompt_position = "top",
preview_cutoff = 120,
},
attach_mappings = function(prompt_bufnr, map)
map("i", "<C-d>", function()
local state = require("telescope.actions.state")
local selected_entry = state.get_selected_entry()
local current_picker = state.get_current_picker(prompt_bufnr)
table.remove(harpoon_files.items, selected_entry.index)
current_picker:refresh(finder())
end)
return true
end,
}):find()
end |
You are not using the plugin as it is designed to be used. You can delete anything from the list by just clicking |
I appreciate your perspective. In the tech world, we all have opinions on various subjects. However, it's important to understand that using a plugin differently doesn't necessarily mean it's being used 'wrong'. |
- Included a function that removes files from harpoon buffers based on the following issue: ThePrimeagen/harpoon#499
Also, no, it doesn't work with telescope UI :) |
What issue are you having that you need harpoon to solve?
It would be nice to use the Telescope picker to also remove files from the list,
and possibly also perform some other list operations, such as rearrange file order.
Why doesn't the current config help?
Currently it is only possible to remove a specific file from a harpoon list with
require('harpoon'):list():remove()
if the file is the currently opened buffer, or editing the list viaharpoon.ui
What proposed api changes are you suggesting?
It would be nice being able to call the remove function specifying an index, something like
require('harpoon'):list():remove(n)
. This would make it possible to write more complex telescope pickers with added functionalityThe text was updated successfully, but these errors were encountered: