Skip to content
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

can not handle git worktree multiple branches #1

Open
matu3ba opened this issue Jul 12, 2022 · 5 comments
Open

can not handle git worktree multiple branches #1

matu3ba opened this issue Jul 12, 2022 · 5 comments

Comments

@matu3ba
Copy link

matu3ba commented Jul 12, 2022

I think this problem is caused by upstream, but not too sure.

If I wan to open an existing worktree, ie master to check some stuff, then I get unrelated (yet cached) files.

The problem does not persist, if I send the files to a quickfixlist and use :cfdo lua require("harpoon.mark").add_file()
or if I manually set the files with

map('n', '<leader>mj', [[<cmd>lua require("harpoon.mark").set_current_at(1)<CR>]], opts) --m means make to 1
map('n', '<leader>mk', [[<cmd>lua require("harpoon.mark").set_current_at(2)<CR>]], opts)
map('n', '<leader>ml', [[<cmd>lua require("harpoon.mark").set_current_at(3)<CR>]], opts)
@matu3ba
Copy link
Author

matu3ba commented Jul 12, 2022

I suspect that harpoon keeps a session file somewhere in /tmp correlating to the cwd, which may or not may be overwritable to prevent accidental session problems (say one opens multiple instances).

I did not suspect that :cfdo lua require("harpoon.mark").add_file() has different behavior on this.

By session I mean the harpoon-internal session tracking, not session files created within neovim with mks. My git worktree master has no session file in it.

@matu3ba
Copy link
Author

matu3ba commented Jul 12, 2022

My workaround is to use add_cmd('HSend', [[:cfdo lua require("harpoon.mark").add_file()]], {}) instead

Please let me know, if this a use case you want to support or otherwise close this issue.

@asbjornhaland
Copy link
Owner

I am currently on vacation and will have a look at this when I'm back. Thanks for using this :-)

@matu3ba
Copy link
Author

matu3ba commented Jul 13, 2022

Have fun on vacation then.

matu3ba added a commit to matu3ba/dotfiles that referenced this issue Jul 15, 2022
nvim
- c++ debugging helpers
- sending files to harpoon
- leap other keybindings to not interfere with nvim-surround
- remove nvim-tags completions, because they interfere with inbuild
  C-n,C-p buffer completions of currently shown buffers
- add nvim-lsp-installer, because its too convenient and nix let me down
  with their inability to provide an undo installation command
- remove tags, because no vim-gutentag setup and overlapping with
  C-n,C-p
  * issue quangnguyen30192/cmp-nvim-tags#5
- telescope-send-to-harpoon has caching problems, most likely from upstream
  harpoon
  * asbjornhaland/telescope-send-to-harpoon.nvim#1
- remove hop.nvim and add leap with -,_ and gs keybindings
  * no overlap with nvim-surround
- gdb has super useful `fin` instruction to finish current scope
- git reset --hard without losing content instructions
@asbjornhaland
Copy link
Owner

I don't know if I understand the problem correctly. Is the problem related to refreshing the marks after changing worktree?

If you:

  • Open telescope
  • Select one or more files (with <TAB>)
  • Use this custom action to send the selected to harpoon
  • Open harpoon menu

What do you see? are the marks present?
If you then change worktree, are the marks present?

--

Harpoon stores marks in a harpoon.json (in XDG_CONFIG) keyed each on branchname/cwd (depending on your config). See the implementation here and here

--

Your workaround uses qflist which should not be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants