Repository navigation
vscode: fix vscode-vim keybindings conflict - #3308
Conversation
vscode-vim extension overrides the `type` command so that it prevents some keypresses to reach the text document editor. It conflicts with our `onEnter` keybinding that is used to support automatic doc comments extending and indentation insertion. The VSCode-native way to implement this would be to use regular expressions, but as per matklad it is considered not acceptable for the language server. Thus we implement it via a `Enter` keybinding that invokes our `onEnter` command which sends a request to rust-analyzer process and applies the appropriate source change recieved from it. At the end of the day we may only apply ad hoc workarounds for conflicting extensions. But vscode has another bug for that. You either cannot use parantheses in `when` condition of a keybinding or it just malfunctions. See an issue about that here: microsoft/vscode#91473 To get the ultimate context, follow this zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Enhanced.20typing
|
Can we involve someone from the Vim extension? Maybe there's a way to detect the search mode. |
|
@johnfn Sorry to ping you for this, but we could use a bit of help here. We're an LSP extension for the Rust language, and we handle This conflicts with the Vim extension and we're trying to avoid that with the changes here. But one issue is that our command still triggers when searching text (with |
|
Ah, that's pretty rough. We had to implement The best way would be to rewrite that section of vscodevim to use a better strategy to gather input from the user and update live (if such an API even exists??). I realize that's kind of a tall order though. I'd imagine you could also do some sort of inter-extension communication - it's a hack but it would work. I don't have enough time to maintain vscodevim any more, unfortunately :( but I'm sure if you asked around on our Slack that someone might be able to help you out. |
|
Thanks for the answer! |
|
It does insert a newline for me IIRC (unless it's a different condition than the one I've tested). Do you happen to know where that vim.mode value comes from? At least this is an improvement, right? |
|
Yeah, I saw the source code of vscode-vim, so I can tell. Might I ask you for steps to reproduce @lnicola ? |
|
@Veetaha never mind, it's working for me this time. I think editing the condition didn't work for me, since it added that binding some 20 times to the JSON. |
|
bors r+ |
Build succeeded |
Closes #3013 I hope
vscode-vim extension overrides the
typecommand so that it preventssome keypresses to reach the text document editor.
It conflicts with our
onEnterkeybindingthat is used to support automatic doc comments extending and
indentation insertion.
The VSCode-native way to implement this would be
to use regular expressions, but as per matklad it is
considered not acceptable for the language server.
Thus we implement it via a
Enterkeybinding thatinvokes our
onEntercommand which does it via the language-server.At the end of the day we may only apply
ad hoc workarounds for conflicting extensions.
But vscode has another bug for that. You
either cannot use parantheses in
whenconditionof a keybinding or it just malfunctions.
See an issue about that here: microsoft/vscode#91473
To get the ultimate context, follow this zulip thread