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

"Comment functionality" in file list? #582

Open
nyaray-bontouch opened this issue Apr 22, 2024 · 2 comments
Open

"Comment functionality" in file list? #582

nyaray-bontouch opened this issue Apr 22, 2024 · 2 comments

Comments

@nyaray-bontouch
Copy link

Dunno if this is totally dumb, but I thought I could at least drop the idea since I'm really enjoying Harpoon2 and realised this might be useful to others.

What issue are you having that you need harpoon to solve?
I would like to write notes in the harpoon file list to remember what I thought yesterday, when I'm checking what I had harpooned when I left. For this purpose, it would be nice if harpoon ignored file names that began with a specific (probably configurable) character, such as '#'.

Why doesn't the current config help?
Leaning on harpoon for regaining context when resuming work the following day.

What proposed api changes are you suggesting?
Adding a config parameter for a comment character (sort of how git allows you to change what it uses in the beginning of comment lines), in order to be able to add comments that don't affect the order of files when using the "open file N in the list" bindings.

@maxrzaw
Copy link

maxrzaw commented May 19, 2024

This probably doesn't make sense as a feature of harpoon. However, there are a couple ways you could modify your config to accomplish this.

You could add a second list with an empty select function and a different keymap.
If you really want the notes in the same list, you could modify the select function of the default list, to detect your special characters and then return.

Here are examples of both approaches:

        local Harpoon = require("harpoon")

        Harpoon:setup({
            settings = {
                save_on_toggle = true,
                sync_on_ui_close = true,
            },
            default = {
                select = function(list_item, list, options)
                    if
                        list_item.value ~= nil
                        and string.sub(list_item.value, 1, 1) == "#"
                    then
                        return
                    end
                    require("harpoon.config")
                        .get_default_config().default
                        .select(list_item, list, options)
                end,
            },
            notes = {
                select = function() end,
            },
        })
        vim.keymap.set("n", "<leader>h", function()
            Harpoon.ui:toggle_quick_menu(Harpoon:list(), {
                title = " Harpoon Marks ",
            })
        end)
        vim.keymap.set("n", "<leader>n", function()
            Harpoon.ui:toggle_quick_menu(Harpoon:list("notes"), {
                title = " Harpoon Notes ",
            })
        end)

I hope this helps!

@nyaray
Copy link

nyaray commented May 21, 2024

Interesting ideas, thank you for your input! Is the select function the same one that's called as when you do the "open Nth harpooned file" command? If it is, I might be able to write a "clever" function that tries picking the first file line after the selection if the selection is not a file.

(Also, oops, wrong account)

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

3 participants