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

feat(picker): make the telescope harpoon-picker behave more like a builtin telescope file-picker #512

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

Conversation

kimabrandt-flx
Copy link

This commit fixes the missing entry.index - in the marks-extension for telescope - which caused the index to always show nil - or rather n… - due to a fixed width of 2, in the dialogue.

This commit also added a dynamic width and left-padding for the index-column, so the index is being right-aligned.

This commit fixes the missing `entry.index` - in the marks-extension for
telescope - which caused the index to always show `nil` - or rather
`n…` - due to a fixed width of 2, in the dialogue.

This commit also added a dynamic width and left-padding for the
index-column, so the index is being right-aligned.
These changes allow the telescope harpoon-picker to behave more like a
builtin telescope file-picker. Both global and individual telescope-
customizations will have an effect.
Improve the `move`- and `delete`-operations, by making them feel
smoother. Also make the movements behave more like "builtin" telescope-
movements.
@kimabrandt-flx kimabrandt-flx changed the title fix(marks): fix missing entry-index feat(picker): make the telescope harpoon-picker behave more like a builtin telescope file-picker Feb 4, 2024
@kimabrandt-flx
Copy link
Author

These changes add some enhancements for the telescope Harpoon Marks-picker.

This change allows the telescope-picker to sort by index. If one of the
search-terms equals an index, it'll get a better score. Partial matches
of an index, will get a slightly better score. Matches with the main
entry - i.e. the filename - will always have the best score; showing
them before an index-match.
iainsimmons pushed a commit to iainsimmons/dotfiles that referenced this pull request Mar 27, 2024
Marks in lualine, custom mapping to delete marks in Telescope
Also see ThePrimeagen/harpoon#512
and ThePrimeagen/harpoon#499
iainsimmons added a commit to iainsimmons/dotfiles that referenced this pull request Apr 2, 2024
Marks in lualine, custom mapping to delete marks in Telescope
Also see ThePrimeagen/harpoon#512
and ThePrimeagen/harpoon#499
@gvolpe
Copy link

gvolpe commented Apr 3, 2024

This is great, thank you for putting up this work!

@ThePrimeagen
Copy link
Owner

If I can get a couple of approvals, I will merge this.

Not know the telescope stuff, so I need someone who can take the lead on reviewing these changes

This can be used to extend and override the key-mappings inside
the `attach_mappings`-function, for example:

```lua
local themes = require("telescope.themes")
local hm_actions = require("telescope._extensions.harpoon_marks.actions")
require("telescope").extensions.harpoon.marks(themes.get_dropdown({
    previewer = false,
    layout_config = { width = 0.6 },
    path_display = { truncate = 10 },
    attach_mappings = function(_, map)
        map("i", "<c-d>", hm_actions.delete_mark_selections)
        map("n", "<c-d>", hm_actions.delete_mark_selections)
        return true
    end,
}))
```
Copy link

@gvolpe gvolpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThePrimeagen I'm not a Telescope expert, but all I can say is this works perfectly! Thank you again @kimabrandt-flx 🙏🏽

@11Firefox11
Copy link

11Firefox11 commented Jun 29, 2024

Tried it out with this code. I don't know telescope, I just tried it out and it works well.

One thing I noticed though is that if you delete an item then the Harpoon indexes will change too, but in telescope the original numbers persist. For example in Telescope: 1, 2, 3, 4, 5 --delete 2nd--> 1, 3, 4, 5 (should be 1, 2, 3, 4 - which it will be if I close and reopen the whole thing).
Sadly I don't know how to update the currently displayed items in telescope so I can't implement this.

@11Firefox11
Copy link

I used it for few days and it doesn't work well. The ordering really breaks when deleting items and then adding new ones. There will be empty rows in the original Harpoon window.

@kimabrandt-flx
Copy link
Author

kimabrandt-flx commented Jul 4, 2024

@11Firefox11
The current Telescope marks-extension, has the same issue: #588
Maybe this could be fixed inside the remove_at-function!? Calling it, seems to leave a blank value (nil) inside the harpoon-list!? I'm not sure if the Telescope-picker should show the blank value, or if the blank value should be removed, inside the harpoon-list?!

I think - when restarting - you could be seeing something related to these issues!? #476, #573

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.

None yet

6 participants