-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
Cannot delete or re-arrange files (using telescope ui) #477
Comments
After reviewing the codebase, I've identified the section responsible for handling the deletion of Harpoon marks within Telescope. The relevant code can be found here. However, it seems that the execution of this code is not achieving the expected result. When attempting to delete a mark, it isn't being removed. My config: |
I've just discovered that a pull request (#471) addressing this issue has already been created by @greidinger-reis. The proposed changes have been implemented, and the pull request is currently under review. Until the pull request is merged, I'll keep this issue open to track its status. Once the PR is merged, I can close this issue. |
I am not on my computer. I don't know who runs the telescope plugin, but whoever does please let me know what course you want (I do not use a telescope harpoon plugin) |
My PR didn't address re-arranging marks. I'm gonna try to make it possible |
Again, I know nothing about the telescope plugin and I'm away from my computer. But the telescope plugin should call resolve displayed with the files from telescope. |
I've made some changes to the telescope-picker in PR #512. Maybe it can be useful!? |
Interesting. When I try to use that same code, and press Here's my lazy config: return {
'ThePrimeagen/harpoon',
branch = 'harpoon2',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
},
config = function()
-- basic config from https://github.com/ThePrimeagen/harpoon/tree/harpoon2
local harpoon = require 'harpoon'
-- REQUIRED
harpoon:setup()
-- REQUIRED
vim.keymap.set('n', '<leader>a', function()
harpoon:list():add()
end)
vim.keymap.set('n', '<C-e>', function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
vim.keymap.set('n', '<C-h>', function()
harpoon:list():select(1)
end)
vim.keymap.set('n', '<C-j>', function()
harpoon:list():select(2)
end)
vim.keymap.set('n', '<C-k>', function()
harpoon:list():select(3)
end)
vim.keymap.set('n', '<C-l>', function()
harpoon:list():select(4)
end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set('n', '<C-S-P>', function()
harpoon:list():prev()
end)
vim.keymap.set('n', '<C-S-N>', function()
harpoon:list():next()
end)
-- 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
local make_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 = require('telescope.finders').new_table {
results = file_paths,
},
previewer = conf.file_previewer {},
sorter = conf.generic_sorter {},
attach_mappings = function(prompt_buffer_number, map)
-- Delete selected entry from the list
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_buffer_number)
print(selected_entry.index)
harpoon:list():remove_at(selected_entry.index)
current_picker:refresh(make_finder())
end)
return true
end,
})
:find()
end
-- telescope keybind
vim.keymap.set('n', '<C-e>', function()
toggle_telescope(harpoon:list())
end, { desc = 'Open harpoon window' })
end,
} |
@codevogel Here my complet config file : return {
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function ()
local harpoon = require("harpoon")
harpoon:setup()
vim.keymap.set("n", "<leader>a", function() harpoon:list():append() end)
vim.keymap.set("n", "<leader>d", function() harpoon:list():remove() end)
vim.keymap.set("n", "<leader>1", function() harpoon:list():select(1) end)
vim.keymap.set("n", "<leader>2", function() harpoon:list():select(2) end)
vim.keymap.set("n", "<leader>3", function() harpoon:list():select(3) end)
vim.keymap.set("n", "<leader>4", function() harpoon:list():select(4) end)
vim.keymap.set("n", "<leader>5", function() harpoon:list():select(5) end)
vim.keymap.set("n", "<leader>6", function() harpoon:list():select(6) end)
vim.keymap.set("n", "<leader>7", function() harpoon:list():select(7) end)
vim.keymap.set("n", "<leader>8", function() harpoon:list():select(8) end)
vim.keymap.set("n", "<leader>9", function() harpoon:list():select(9) end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<C-S-P>", function() harpoon:list():prev() end)
vim.keymap.set("n", "<C-S-N>", function() harpoon:list():next() end)
-- 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
local make_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 = require("telescope.finders").new_table({
results = file_paths,
}),
previewer = conf.file_previewer({}),
sorter = conf.generic_sorter({}),
attach_mappings = function(prompt_buffer_number, map)
-- Delete selected entry from the list
map(
"i",
"<C-d>", -- your mapping here
function()
local state = require("telescope.actions.state")
local selected_entry = state.get_selected_entry()
local current_picker = state.get_current_picker(prompt_buffer_number)
harpoon:list():removeAt(selected_entry.index)
current_picker:refresh(make_finder())
end
)
return true
end
}):find()
end
vim.keymap.set("n", "<C-e>", function() toggle_telescope(harpoon:list()) end,
{ desc = "Open harpoon window" })
end
},
{
"letieu/harpoon-lualine",
dependencies = {
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
}
},
}
} |
I'm pretty much using this, line for line (apart from the harpoon-lualine plugin and some keybinds are different). |
@codevogel i think this is the problem. Maybe try to paste my code and try it. |
using the removeAt method now gives an error about a nil value, even without using telescope have any of you ran into that? |
|
I configured harpoon to use telescope UI based on the Docs but I cannot delete or re-arrange the files that were added. Though when using default UI I am able to delete and re-arrange the file.
I guess the issue maybe because when using telescope UI the default field is to Insert text to search for a file like in image:
The text was updated successfully, but these errors were encountered: