johtela / vscode-modaledit

Configurable Modal Editing in VS Code
https://johtela.github.io/vscode-modaledit/docs/README.html
Other
89 stars 8 forks source link

is it possible to bind keys in modaledit with when clauses? #28

Open zhaojiangbin opened 3 years ago

zhaojiangbin commented 3 years ago

In vscode I have the rust-analyzer extension for programming in Rust. This extension has a special command for the Enter key: https://rust-analyzer.github.io/manual.html#on-enter. It requires to have the following binding in keybindings.json:

    {
        "key": "Enter",
        "command": "rust-analyzer.onEnter",
        "when": "editorTextFocus && !suggestWidgetVisible && editorLangId == rust"
    },

Becase keys defined in keybindings.json can only run a single command, not "sequence of commands" like those in modaledit.keybindings, I cannot make the Enter key to run the "rust-analyzer.onEnter" command and activate the insertion mode.

Is it possible to bind this "rust-analyzer.onEnter" command to "\n" in modaledit.keybindings when editorLangId == rust, while keeping the existing "\n" behaviour for other programming languages?

OldStarchy commented 1 year ago

https://marketplace.visualstudio.com/items?itemName=ryuta46.multi-command

digitalmaster commented 3 months ago

I had a similar question yesterday... wanted to use "when" clause variables like suggestWidgetVisible in "condition" arguments. Not sure if it's possible tho.