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

Need help adding a conditional keybinding to an existing menu, not sure how to do so based on documentation #22

Open
macintacos opened this issue Nov 6, 2020 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@macintacos
Copy link

Hello! I'm following this documentation section about overriding conditional bindings, and it's not immediately obvious to me how to do so so I wanted to open an issue about it.

Let's say have a command foo.bar that I want to add to the x submenu for major mode for the Markdown language. How would I go about adding that to my settings? Lets say I want to map it to be SPC m x k, since that's something I'm actively having trouble getting set up, but it honestly doesn't really matter what it is - I don't want to replace anything that is currently there, I just want to add a new command to the menu. How would I do that?

Once I get clarity here, I'll propose some changes to the documentation, because the way it's currently written doesn't make it very explicit how to go about this (at least for me). Thanks!

@stevenguh
Copy link
Member

I assume SPC m x is a sub menu already exists, and you are just adding k to it. The following json should work, and you can change languageId:javascript to your condition.

{
  "whichkey.bindingOverrides": [
    {
      "keys": ["m", "languageId:javascript", "x", "k"],
      "name": "foo bar",
      "type": "command",
      "command": "foo.bar",
    }
  ]
}

I guess this section https://vspacecode.github.io/docs/extra#overrides can be improved?

@macintacos
Copy link
Author

macintacos commented Nov 6, 2020

Ugh of course it was just the ordering I messed up! For whatever reason I was thinking that the "x","k" would come before the languageId (so "m", "x", "k", "languageId:markdown" instead of what you provided). If that's the intended ordering then yeah I think the documentation should be improved, if only to give that kind of example. I'll open a PR soonish to get that in there, thanks!

@stevenguh stevenguh added the documentation Improvements or additions to documentation label Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants