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

feature: Override/remove presets for "misc" keys #386

Closed
1 task done
amaanq opened this issue Jan 6, 2023 · 2 comments · Fixed by #440
Closed
1 task done

feature: Override/remove presets for "misc" keys #386

amaanq opened this issue Jan 6, 2023 · 2 comments · Fixed by #440
Labels
enhancement New feature or request

Comments

@amaanq
Copy link

amaanq commented Jan 6, 2023

Did you check the docs?

  • I have read all the which-key.nvim docs

Is your feature request related to a problem? Please describe.

Well it's a specific problem, I rebinded gx to open a link under the cursor, but the desc I give it is not being overridden and still has the default "Open the file under cursor with system app". It is possible to delete/make the presets nil for those in presets.operators, but misc is local. I also don't want to delete every g* preset, just those I rebind.

Describe the solution you'd like

Ability to rebind/rename preset misc keybinds without having to completely remove them

Describe alternatives you've considered

Might make my own PR for this

Additional context

I could be completely dumb and missed an obvious solution

@amaanq amaanq added the enhancement New feature or request label Jan 6, 2023
@amaanq
Copy link
Author

amaanq commented Jan 6, 2023

I submitted a pr that fixes this, so now in my config for which-key that's loaded by lazy I have something like this:

{
    "folke/which-key.nvim",
    event = "VeryLazy",
    dev = true,
    config = function()
      local misc = require("which-key.plugins.presets.misc")
      misc.misc.g.gf = nil
      misc.misc.g.gx = nil
      local wk = require("which-key")
      wk.setup({
        plugins = { spelling = true },
        key_labels = { ["<leader>"] = "SPC" },
      })
      wk.register({
        mode = { "n", "v" },
        ["g"] = { name = "+goto" },
        ["]"] = { name = "+next" },
        ["["] = { name = "+prev" },
        ["<leader>b"] = { name = "+buffer" },
        ["<leader>c"] = { name = "+code" },
        ["<leader>cl"] = { name = "+lsp" },
        ["<leader>f"] = { name = "+file" },
        ["<leader>g"] = { name = "+git" },
        ["<leader>h"] = { name = "+help" },
        ["<leader>n"] = { name = "+noice" },
        ["<leader>o"] = { name = "+open" },
        ["<leader>q"] = { name = "+quit/session" },
        ["<leader>s"] = { name = "+search" },
        ["<leader>t"] = { name = "+toggle" },
        ["<leader>x"] = { name = "+diagnostics/quickfix" },
        ["<leader>w"] = { name = "+windows" },
        ["<leader><tab>"] = { name = "+tabs" },
      })
    end,
  },

While not the prettiest way, it gets the job done and gf/gx are now named how I'd like it to be :)

Please feel free to fix it in your own way, I'm sure that'd be a lot better than what I did 😆

@madsonic
Copy link

madsonic commented Mar 6, 2023

FWIW, I was not able to get the other presets removed as well including those that are not misc i.e. operators, motions, text_objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants