Closed NTBBloodbath closed 3 years ago
you need to specify a mode. i think that should fix it.
so wk.register({['v'] = 'which_key_ignore'}, {mode = 'n'})
and wk.register({['v'] = 'which_key_ignore'}, {mode = 'v'})
nevermind. i'm getting this error after timeoutlen if i just press v
once in normal mode:
Strange, I just placed it and it didn't give errors, however instead of showing +Visual Character Mode
, it shows +which_key_ignore
:thinking:
Maybe it's not possible to disable triggering WhichKey in visual mode (for now), although it's not something that is very annoying
The correct way to disable this would be to not load the operators
preset and configure operators manually:
{
plugins = {
-- ...
presets = {
operators = false
-- ..
},
},
-- add operators that will trigger motion and text object completion
-- to enable all native operators, set the preset / operators plugin above
operators = {
d = "Delete",
c = "Change",
y = "Yank (copy)",
["g~"] = "Toggle case",
["gu"] = "Lowercase",
["gU"] = "Uppercase",
[">"] = "Indent right",
["<lt>"] = "Indent left",
["zf"] = "Create fold",
["!"] = "Filter though external program",
-- ["v"] = "Visual Character Mode",
gc = "Comments"
},
}
Although, this seems a bit verbose to just disable one operator. I'll see if I can come up with an easier way to do this.
Thank you very much, it works great :smiley:
Should I close the issue or will it be closed when making changes?
I think I'll just add some proper documentation on how to set up operators, motions and text objects and how the preset works in regards to that. You can leave it open for now :)
Understood, thank you very much again :slightly_smiling_face:
Although, this seems a bit verbose to just disable one operator. I'll see if I can come up with an easier way to do this.
For anyone still following this issue or views it in the future, this plugin's author, folke, did document how to do this in the README.
How to disable some operators? (like v)
-- make sure to run this code before calling setup() -- refer to the full lists at https://github.com/folke/which-key.nvim/blob/main/lua/which-key/plugins/presets/init.lua local presets = require("which-key.plugins.presets") presets.operators["v"] = nil
I tried it and it works for me.
Update: @joeynguyen's method doesn't work anymore on the latest version of which-key. Instead, add the following to which-key's options in the call to setup()
(or in opts = { ... }
, if using lazy):
defer = function(ctx)
return ctx.mode == "v" or ctx.mode == "V" or ctx.mode == "<C-V>"
end,
Is there a way to stop triggering WhichKey at
v
key mappings? I'm trying to enter visual mode without triggering it but it isn't possibleAlready tried with
but the key bindings keep coming out when pressing v :confused: