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.42k stars 177 forks source link

Issues with normal execute sequence #93

Closed AckslD closed 4 months ago

AckslD commented 3 years ago

I'm getting some strange behaviour when trying to escape characters through :execute "normal cmd" which seems to be caused by whichkey as far as I can tell.

If I run:

:execute "normal! vw\<Esc>"

the cursor moves one word forward and importantly normal mode is active after the command. However the strange thing is that if I omit the exclamation mark I'm left in visual mode after the command.

Furthermore I tried to just disable the presets.operators for now but if seems that the mapping is still there. Ie map v gives

n  v           * <Cmd>lua require("which-key").show("v", {mode = "n", auto = true})<CR>

I tried to disable it as follows:

require("which-key").setup{
    presets = {
        operators = false,
    }
}
folke commented 3 years ago

I think I know what's going on here.

You probably have other keymaps defined under v. So which-key will still trigger for those.

<esc> is used to exit which-key, and that key won't be fed, so you'll remain in visual mode.

I'll see if I can fix this.

The fix would be to only interprete <esc> as exit which-key when which-key is actually visible and to feed it back in other cases.

AckslD commented 3 years ago

I see! That makes sense! Thanks for your reply :) There are indeed some other mappings starting with v, not sure where they come from though haha:

n  vaÞ         * <Nop>
n  viÞ         * <Nop>
n  vÞ          * <Nop>
n  v           * <Cmd>lua require("which-key").show("v", {mode = "n", auto = true})<CR>  
AckslD commented 3 years ago

Btw, which key still shows up with info about visual mode commands after pressing v even if I disabled the operator plugin. Is that intended behaviour or a bug?

folke commented 3 years ago

those <nop> ones are also which-key, but they shouldn't be there in case you disabled the operators.

folke commented 3 years ago

yeah, probably not. That's what I was thinking. Might be a bug indeed

AckslD commented 3 years ago

Hold on, I think it's my mistake, it should be:

require("which-key").setup{
    plugins = {
        presets = {
            operators = false,
        },
    },
}

right?

folke commented 3 years ago

yep, that should work. Just tested it

AckslD commented 3 years ago

@folke is this fixed? :)

folke commented 3 years ago

Oh sorry, I only read the last comments. Not fixed :)

I'll see if I can fix it in a bit.

imkerberos commented 3 years ago

I focused this issue. My error sequence is 'a'. show you the output of command ":nmap a".

nosaÞ nosa lua require("which-key").show("a", {mode = "", auto = true})

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.