folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.12k stars 163 forks source link

bug: Does not list `gw` #623

Closed mangelozzi closed 2 months ago

mangelozzi commented 2 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.11.0-dev-322+ge7020306a Build type: RelWithDebInfo LuaJIT 2.1.1716656478

Operating system/version

Ubuntu 22.04

Describe the bug

press g and wait for which key to pop up w will not be listed, but gw is a very helpful motion for formatting text to say 80 chars (depends on textwidth).

Add this to the options setup object didnt help either:

        operators = {
            gw = "Wrap lines",
        }

I had to do this to get which key to register it (map gw to gw and add a description):

vim.keymap.set({"", "!"}, "gw", "gw", { noremap = true, desc = "Wrap lines" })

Looking at the entire list of operator it is also missing gf, which is similar to gw. Maybe a good time to also add gc for commenting (although it is in your README.md config.

M.operators = {
  d = "Delete",
  c = "Change",
  y = "Yank (copy)",
  ["g~"] = "Toggle case",
  ["gu"] = "Lowercase",
  ["gU"] = "Uppercase",
  [">"] = "Indent right",
  ["<lt>"] = "Indent left",
  ["zf"] = "Create fold",
  ["!"] = "Filter through external program",
  ["v"] = "Visual Character Mode",
  -- ["V"] = "Visual Line Mode",
}

Steps To Reproduce

  1. Press g
  2. Wait for which key to pop up

Expected Behavior

See something like w -> format text listed

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "folke/which-key.nvim", opts = {} },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
folke commented 2 months ago

which-key does not show an exhaustive list of all Neovim mappings. There's simply too many.

mangelozzi commented 2 months ago

Okay fair enough, but surely adding this to the options object is supposed to add the mapping to which key?

operators = {
    gw = "Wrap lines",
}
mangelozzi commented 2 months ago

To quote your README.md:

  -- add operators that will trigger motion and text object completion
  -- to enable all native operators, set the preset / operators plugin above

Note how it says "all native operators"

Yes there any many mappings, but there arent that many operators, just a hand full of them, and gf and gw are native operators.

folke commented 2 months ago

seriously, just let it go. I'm not going to add every mapping. You can add it to your own config.

mangelozzi commented 1 month ago

The impression I get is that you think I am trying to get you to add the mapping so I don't have. I understand you have created a lot of plugins, and don't have time to spend time babying people on how to use them. For your information I had already added this mapping before your reply, for anyone else:

    wk.register({
        -- Wrap text (built in) - default is gq, but requires textwidth to be none zero, built in, but does not show up in which key by default
        gw = "Wrap text", 
    })

The reason I took the time to document the issue is because I actually thought it was a bug and was trying to help improve the software. I thought whichkey is supposed to help people learn mappings. The readme is technically incorrect and misleading and was trying to help any future people encountering the same problem. But I see now whichkey is not about learning new hotkeys, but rather it's about documenting which keys you wish to not forget.