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

Support when for contextual keybindings #3994

Closed
denisidoro opened this issue Aug 25, 2019 · 1 comment
Closed

Support when for contextual keybindings #3994

denisidoro opened this issue Aug 25, 2019 · 1 comment

Comments

@denisidoro
Copy link

denisidoro commented Aug 25, 2019

Is your feature request related to a problem? Please describe.
I'm not able to set keybindings contextually. For example, I would like to set <leader> + m + p as an action to preview content, and that depends on the programming language. At a higher level, I'm trying to replicate Spacemacs's major modes.

Using when seems to be a no-op. In the example below, both commands are executed regardless of the current editorLangId.

Describe the solution you'd like
To support when in elements inside commands, as in:

{"before":   ["<leader>", "m", "p"], 
 "after":    [], 
 "commands": [{"command": "markdown.showPreviewToSide", "args": [], "when": "editorLangId == 'markdown'"},
              {"command": "html.previewPage", "args": [], "when": "editorLangId == 'html'"}]}

Alternatively, when could be supported in the command root:

{"before":   ["<leader>", "m", "p"], 
 "after":    [], 
 "when":     "editorLangId == 'markdown'",
 "commands": [{"command": "markdown.showPreviewToSide", "args": []}]}

Describe alternatives you've considered
Set shorcuts in keybindings.json. I wouldn't be able to differ between vim modes, though. And I guess it would make my <leader> inconsistent.

@J-Fields
Copy link
Member

Closing as duplicate of #2030

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants