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

feat(keybindings): global window resize/split #1257

Merged

Conversation

martin-braun
Copy link
Contributor

@martin-braun martin-braun commented Jul 4, 2023

Idea is to have global window split and resize keybindings outside of Neovim. Unfortunately, this doesn't work as it should be.

VSCode keybindings are locale aware. So instead of mapping the character, it requires to map the physical key, which is not what we want. Vim isn't aware of physical keys, so it reacts on characters which will result in different key strokes depending on the keyboard layout.

I'm using a German macOS keyboard layout (ISO whatever), VSCode won't let me map most of the keybindings to a locale-independent keymap:

Screenshot 2023-07-04 at 08 55 55

Interestingly, the behavior we strive for seems to work for =:

Screenshot 2023-07-04 at 08 57 03

So it seems to be possible, it's just not feature complete(?).

@theol0403
Copy link
Member

Aside from the localisation issues, is this ready for merge?

@martin-braun
Copy link
Contributor Author

martin-braun commented Jul 5, 2023

@theol0403 I'd like to know if there is an easy fix for the location issues. I think the worse case is that it will only work partially, depending on your local.

If you decide to merge it, we should open an issue and keep track of it. It shouldn't break anything if you merge it now.

@theol0403
Copy link
Member

What if you tried ctrl+w shift+.?

@martin-braun
Copy link
Contributor Author

@theol0403 wdym? shift+. starts a command, even when followed by ctrl+w in Neovim. Why mapping this one? There are several bindings not working in my locale, not just one.

@theol0403
Copy link
Member

theol0403 commented Jul 5, 2023

Sorry, I know nothing about your locale, but I thought maybe binding the physical keys would fix the problem. That assumes shift+. = > for you, however.

I see the problem is the opposite.

@martin-braun
Copy link
Contributor Author

martin-braun commented Jul 5, 2023

@theol0403 This is my layout:

German macOS keyboard layout

To make it work properly, I have to do:

    {
        "key": "ctrl+w =",
        "command": "workbench.action.evenEditorWidths",
        "when": "!editorTextFocus"
    },
    {
        "key": "ctrl+w shift+-",
        "command": "workbench.action.toggleEditorWidths",
        "when": "!editorTextFocus"
    },
    {
        "key": "ctrl+w [Backquote]",
        "command": "workbench.action.decreaseViewWidth",
        "when": "!editorTextFocus"
    },
    {
        "key": "ctrl+w shift+[Backquote]",
        "command": "workbench.action.increaseViewWidth",
        "when": "!editorTextFocus"
    },
    {
        "key": "ctrl+w +",
        "command": "workbench.action.increaseViewHeight",
        "when": "!editorTextFocus"
    },
    {
        "key": "ctrl+w -",
        "command": "workbench.action.decreaseViewHeight",
        "when": "!editorTextFocus"
    },
    {
        "key": "ctrl+w s",
        "command": "workbench.action.splitEditorDown",
        "when": "!editorTextFocus"
    },
    {
        "key": "ctrl+w v",
        "command": "workbench.action.splitEditorRight",
        "when": "!editorTextFocus"
    },

Hopefully you can see where this is going. VSCode wants physical keys (which are named by the US keyboard in [ ] brackets), so that no matter which locale you have, the key to press is always at the same position. However, Vim wants logical keys, so the key position you have to press depends on your locale.

If I map shift+. I would actually map the function to my : character in my locale, so your proposal would only for US keyboard layouts. Anybody with a different locale would expect those functions to be on a different physical keys, because Vim wants proper characters, not physical keys. I.e. we Germans hit shift+4 to go to the end of the line, or we hit shift+. to enter command mode, this is familiar for us and it should be translated to vscode-neovim in the same way.

VSCode needs to allow to map a logical key. Unless they offer a flag or something like that, we cannot map Vim commands that involve special characters properly for all keyboard layouts. Interestingly, this behavior doesn't happen for z or y which are swapped on the German keyboard.

Also, please upvote microsoft/vscode#186961, because we need to show them that we need this functionality.

@xiyaowong
Copy link
Collaborator

Looks good! Very convenient shortcuts

@theol0403
Copy link
Member

I suppose nothing can be done other than to merge the existing ability.

@theol0403
Copy link
Member

@xiyaowong can you rebase?

@xiyaowong
Copy link
Collaborator

Wait a minute

@xiyaowong xiyaowong changed the title feat: global window resize/split feat(keybindings): global window resize/split Oct 30, 2023
@xiyaowong
Copy link
Collaborator

xiyaowong commented Oct 30, 2023

Maybe change the script name navigation to view? @theol0403

@theol0403
Copy link
Member

Sure, or something related to vscode bindings like vscode-integration.

@xiyaowong xiyaowong merged commit 9cb8aff into vscode-neovim:master Oct 30, 2023
8 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants