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

Disable visual mappings #26

Closed
NTBBloodbath opened this issue Apr 29, 2021 · 8 comments
Closed

Disable visual mappings #26

NTBBloodbath opened this issue Apr 29, 2021 · 8 comments

Comments

@NTBBloodbath
Copy link

NTBBloodbath commented Apr 29, 2021

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 possible

Already tried with

wk.register({['v'] = 'which_key_ignore'})

but the key bindings keep coming out when pressing v 😕

@klooj
Copy link

klooj commented Apr 29, 2021

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'})

@klooj
Copy link

klooj commented Apr 29, 2021

nevermind. i'm getting this error after timeoutlen if i just press v once in normal mode:
image

@NTBBloodbath
Copy link
Author

NTBBloodbath commented Apr 29, 2021

Strange, I just placed it and it didn't give errors, however instead of showing +Visual Character Mode, it shows +which_key_ignore 🤔

Maybe it's not possible to disable triggering WhichKey in visual mode (for now), although it's not something that is very annoying

Screenshot_20210429_194419

@folke
Copy link
Owner

folke commented Apr 30, 2021

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.

@NTBBloodbath
Copy link
Author

Thank you very much, it works great 😃

Should I close the issue or will it be closed when making changes?

@folke
Copy link
Owner

folke commented Apr 30, 2021

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 :)

@NTBBloodbath
Copy link
Author

Understood, thank you very much again 🙂

@folke folke closed this as completed Apr 30, 2021
@joeynguyen
Copy link

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.

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

No branches or pull requests

4 participants