Open pmielle opened 12 months ago
hey,
I think it would be useful to be able to disable cycling when using nav_next() and nav_prev().
For example: if I have 4 harpoons and I am currently at the 4th one, I would like
nav_next()
to do nothing. Same thing fornav_prev()
on nav(1)I know it would make sense for some of my workflows where I tend to go deeper and deeper into a codebase, setting checkpoints along the way
thanks for the hard work!
What about using tag stack instead?
Thank you for your answer! disclaimer: I am not familiar with tag stacks
I like harpoon because I manually set which file I want to keep in my save list and which one I don't. If I understand correctly, tab stack keeps track of every jump I make unconditionally.. which is not exactly what I would like to have. And on top of that, I would guess that tab stacks do not persist when closing and opening back vim, but maybe I'm wrong here
but I get what you mean: tab stacks solve the "go deeper and deeper into a codebase"-thing I described. Still, I tend to prefer harpoon for the reasons I mentioned above
@pmielle i am not really understanding this
how would you envision this working? would there be a harpoon function you would call to go into this "don't change state" mode? i am just unsure if i want to support this but i want to understand it.
oh no no no. I would just like to have a setting to prevent harpoon to loop back to the beginning of the list when hitting nav_next()
on the last item. Sorry if I'm not making myself clear (I'm french..)
oh yes! i see i see. this makes perfect sense. that seems like a reason able option
i am now releasing Harpoon2 as the new harpoon (interface change, but TONS of new power + less features (which gives more options for more features))
ooh awesome! looking forward to it. thanks for your feedback + for your content in general!
i am going to reopen this issue and implement it in settings
object for harpoon 2
@pmielle this issue can be closed, my PR to include this was merged some weeks ago.
That's weird. This setting has no effect for me. My harpoon2 will not wrap.
I'm on NVIM v0.10.0 and my config is this:
return {
"ThePrimeagen/harpoon",
lazy = false,
branch = "harpoon2",
init = function()
local harpoon = require("harpoon")
harpoon:setup({
settings = {
save_on_toggle = true,
ui_nav_wrap = true,
},
})
-- harpoon append file to list
vim.keymap.set("n", "<leader>ha", function()
harpoon:list():append()
end)
-- harpoon menu toggle
vim.keymap.set("n", "<leader>hh", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<C-PageUp>", function()
harpoon:list():prev()
end, { desc = "Previous harpooned file" })
vim.keymap.set("n", "<C-PageDown>", function()
harpoon:list():next()
end, { desc = "Next harpooned file" })
-- direct harpoon files
vim.keymap.set("n", "<leader>1", function()
harpoon:list():select(1)
end, { desc = "Switch to harpoon 1" })
vim.keymap.set("n", "<leader>2", function()
harpoon:list():select(2)
end, { desc = "Switch to harpoon 2" })
vim.keymap.set("n", "<leader>3", function()
harpoon:list():select(3)
end, { desc = "Switch to harpoon 3" })
vim.keymap.set("n", "<leader>4", function()
harpoon:list():select(4)
end, { desc = "Switch to harpoon 4" })
vim.keymap.set("n", "<leader>5", function()
harpoon:list():select(5)
end, { desc = "Switch to harpoon 5" })
vim.keymap.set("n", "<leader>6", function()
harpoon:list():select(6)
end, { desc = "Switch to harpoon 6" })
vim.keymap.set("n", "<leader>7", function()
harpoon:list():select(7)
end, { desc = "Switch to harpoon 7" })
vim.keymap.set("n", "<leader>8", function()
harpoon:list():select(8)
end, { desc = "Switch to harpoon 8" })
vim.keymap.set("n", "<leader>9", function()
harpoon:list():select(9)
end, { desc = "Switch to harpoon 9" })
-- 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", "<leader>fh", function()
toggle_telescope(harpoon:list())
end, { desc = "Harpoon files" })
end,
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
}
@lpanebr it looks like the attribute was deleted in another PR that was merged, I'm assuming by mistake. #461 PR was opened to put it back in.
Edit:
Cycling stopped working for list:next()
and list:prev()
, so I fixed it in #562 :)
Cycling works as expected and does not wrap by default, but can be enabled by passing an option to the list():next({})
and list():prev({})
methods:
require("harpoon"):list():next({ ui_nav_wrap = true })
require("harpoon"):list():prev({ ui_nav_wrap = true })
hey, I think it would be useful to be able to disable cycling when using nav_next() and nav_prev().
For example: if I have 4 harpoons and I am currently at the 4th one, I would like
nav_next()
to do nothing. Same thing fornav_prev()
on nav(1)I know it would make sense for some of my workflows where I tend to go deeper and deeper into a codebase, setting checkpoints along the way
thanks for the hard work!