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

Include description on keybinds #47

Closed
Hudison opened this issue Feb 14, 2023 · 5 comments · Fixed by #51
Closed

Include description on keybinds #47

Hudison opened this issue Feb 14, 2023 · 5 comments · Fixed by #51

Comments

@Hudison
Copy link

Hudison commented Feb 14, 2023

I recently got this plugin recommended by a friend and I use which-key, when I asked what the key binds are, he said g? and look at the description in which-key, the thing is that there is no description for the key binds. Since it's a very simple and fast change, that makes it more user-friendly, not only for which-key, but also when you search for the keybindings available.

My suggestion is to just add the desc property on the default key binds.

        vim.keymap.set("n", "g?p", function()
            return M.debugprint()
        end, {
            expr = true,
            desc = "debug line below", --<
        })
        vim.keymap.set("n", "g?P", function()
            return M.debugprint({ above = true })
        end, {
            expr = true,
            desc = "debug line above",  --<
        })
        vim.keymap.set("n", "g?v", function()
            return M.debugprint({ variable = true })
        end, {
            expr = true,
            desc = "debug variable below",  --<
        })
        vim.keymap.set("n", "g?V", function()
            return M.debugprint({ above = true, variable = true })
        end, {
            expr = true,
            desc = "debug variable above",  --<
        })
        -- .... and so on
@andrewferrier
Copy link
Owner

@Hudison I think this is an excellent idea. One moment...

@andrewferrier
Copy link
Owner

andrewferrier commented Feb 14, 2023

@Hudison so I've done that now (it didn't take long ;) ). Hopefully that's a good quality-of-life improvement. I don't use which-key (I never used to find it reliable) but I quickly installed it to test this and I have to say I really like it, I might even keep it :) Irrespective, hopefully this is helpful.

Thanks for highlighting the request, and hope you're enjoying using the plugin.

(Oh and let me know if you have any improvements to the descriptions I've added, I tried to keep them brief but clear...)

@Hudison
Copy link
Author

Hudison commented Feb 14, 2023

@andrewferrier Thank you for the quick response and improvement. I like which-key a lot since I'm new to neovim, and that helps me a lot with remembering things, especially the possible available things after a command.

The descriptions in my opinion are on point, on my editor I can see the full description, so I think they are clear and succinct.

Thank you again for the response and for the very handy plugin.

@aemonge
Copy link

aemonge commented Mar 28, 2023

Do it like this:

table.insert(M, {
    "andrewferrier/debugprint.nvim",
    config = function()
        local opts = {
            create_keymaps = false,
            create_commands = false,
        }
        require("debugprint").setup(opts)
        local fn = function ()
            -- Note: setting `expr=true` and returning the value are essential
            -- It's also important to use motion = true for operator-pending motions
            return require("debugprint").debugprint({ motion = true, variable = true })
        end

        require("which-key").register({
            d = { fn,  "Debug Print" }
        }, {
            mode = "n",
            prefix = "<leader>",
            buffer = nil,
            expr = true,
            silent = true,
            noremap = true,
            nowait = true,
        })
    end,
})

@andrewferrier
Copy link
Owner

@aemonge that's certainly an option, thanks. Worth clarifying that I've added the descriptions to debugprint now, though.

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 a pull request may close this issue.

3 participants