-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
[Feature request] Possibility to have a Git branch context List #625
Comments
Similar to that i guess |
There is somethings with a |
I found how to do it. Here is the required functions and how to use it. -- P.S. branchFeature is just an example here and should be replace by your git branch name
-- Add the file in the branchFeature
require("harpoon"):list("branchFeature"):add()
-- Show the list branchFeature
require("harpoon").ui:toggle_quick_menu(require("harpoon"):list("branchFeature")) I will test it and i may create a PR to add that info in the readme? |
Here is a more complete example: {
"ThePrimeagen/harpoon",
branch = "harpoon2",
opts = {
settings = {
save_on_toggle = true,
sync_on_ui_close = true,
},
},
config = function()
require("harpoon").setup()
end,
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
},
keys = {
{
"<leader>a",
function()
local pipe = io.popen("git branch --show-current")
repeat
local c = pipe:read(4 * 1048576)
if c then
require("harpoon"):list(c):add()
end
until not c
pipe:close()
end,
desc = "Harpoon - Add file related to current git branch"
},
{
"<leader><leader>e",
function()
local pipe = io.popen("git branch --show-current")
repeat
local c = pipe:read(4 * 1048576)
if c then
require("harpoon").ui:toggle_quick_menu(require("harpoon"):list(c))
end
until not c
pipe:close()
end,
desc = "Harpoon - Toggle quick menu related to current git branch"
}
}
}
|
@t1gu1 I think this can simplify your config (I took the crucial part for taking the branch name from you, which I didn't know how to do): harpoon:setup({
settings = {
key = function()
local pipe = io.popen("git branch --show-current")
if pipe then
local c = pipe:read("*l"):match("^%s*(.-)%s*$")
pipe:close()
return c
end
return nil
end,
},
})
|
BTW, there appears to be a bug in the |
What issue are you having that you need harpoon to solve?
First, I really love harpoon! But I always find myself to delete all files in harpoon context to reset it when starting a different feature when creating a new branch in projects I works on.
What proposed api changes are you suggesting?
It would be really nice to have something like a
Global harpoon for the project context
and another for agit branch context
, since the files for a new feature are generally different.How to?
bool
to switch betweenglobal context
andgit branch context
(Feature context) would be perfect!The text was updated successfully, but these errors were encountered: