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

Harpoon 2: Improve telescope setup documentation #471

Open
wants to merge 7 commits into
base: harpoon2
Choose a base branch
from

Conversation

johnpgr
Copy link

@johnpgr johnpgr commented Jan 2, 2024

The current documentation in README.md on setting Harpoon 2 with telescope is incomplete.
It does not open the buffer you selected in the picker with <CR>
It does not have any way to remove a buffer from the list using the picker.

The code snippet added to README.md in my commit is going to help users that would like to use Harpoon 2 with telescope.

@nirmitjoshi
Copy link

nirmitjoshi commented Jan 7, 2024

Quick question: To remove the clutter in readme can't we just modify and make marks.lua requirable?

@ThePrimeagen
Copy link
Owner

@nirmitjoshi mark.lua is legacy harpoon. Harpoon 2 Is the new harpoon.

If you modify that, I will not merge it :)

@nirmitjoshi
Copy link

@greidinger-reis can you also add default keymaps for re-arranging files, just to make the functionality more clear

@johnpgr
Copy link
Author

johnpgr commented Jan 12, 2024

@nirmitjoshi I'm trying to get that done, but telescope doesn't provide any functions to easily re-arrange list items, so I'm having some trouble implementing my own, since I'm relatively new to telescope

@johnpgr
Copy link
Author

johnpgr commented Jan 12, 2024

It looks like there is an implementation of that in marks.lua I'll try to copy that

@johnpgr
Copy link
Author

johnpgr commented Jan 12, 2024

There you go. I added a mark rearranging feature to the PR. However this makes this setup a lot longer, it might be time to rewrite it into a harpoon2 telescope plugin.
I also left some comments in it, that might not be adequate to be in a readme file. If there's a problem with that I'll remove them

@bryanvaz
Copy link

bryanvaz commented Mar 9, 2024

+1
Manually copied the config, and now Harpoon2+Telescope is almost as awesome as TJ's doggo

@ilan-schemoul
Copy link

ilan-schemoul commented Mar 18, 2024

Hello,
@ThePrimeagen I feel like what @johnpgr offers makes sense : this should be its own plugin. We don't want people copy pasting + maintaining manually +200 lines of codes for a basic feature.

Furthermore this issue of partial telescope support, incomplete readme.md, no native support for terminals make me wonder why v1 is "deprecated". Active development in on v2 but v2 seems experimental. Also you may want to add a tag or a branch for v1 so people don't have unexpected breaking changes.

Anyway for anyone wanting to switch from v2 to v1 if you a bug saying can't derefence config of nil init.lua:270 (or something like that) you should rm ~/.local/share/nvim/harpoon.json (you'll lose harpoon data)

@gvolpe
Copy link

gvolpe commented Apr 3, 2024

I've tried this and it almost works. The remaining items after re-opening Telescope represent an incomplete list.

For instance, if you initially have 5 items, and delete just one, then close Telescope and re-open it once again, you will find only 2 items in the list, when there should be 4 items.

Anyone else experiencing the same issue?

@gvolpe
Copy link

gvolpe commented Apr 3, 2024

This works great: #512

@johnpgr
Copy link
Author

johnpgr commented Apr 3, 2024

@gvolpe Yes, I noticed this bug, I got it working by using a indexOf helper function to get the index of the mark in the list correctly. Here it is if you want, and I will include it in this PR

local function list_indexOf(list, predicate)
    for i, v in ipairs(list) do
        if predicate(v) then
            return i
        end
    end
    return -1
end

Use it in the C-d keymap

map({ 'n', 'i' }, '<C-d>', function(prompt_bufnr)
                local curr_picker = action_state.get_current_picker(prompt_bufnr)
                curr_picker:delete_selection(function(selection)
                    local mark_idx = list_indexOf(harpoon_files.items, function(v)
                        return v.value == selection[1]
                    end)
                    if mark_idx == -1 then
                        return
                    end

                    harpoon:list():removeAt(mark_idx)
                end)
            end)

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

Successfully merging this pull request may close these issues.

7 participants