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

Better support for international keyboards #9862

Closed
markus-oberhumer opened this issue Mar 13, 2024 · 18 comments
Closed

Better support for international keyboards #9862

markus-oberhumer opened this issue Mar 13, 2024 · 18 comments
Labels
C-enhancement Category: Improvements

Comments

@markus-oberhumer
Copy link

I'm using a German keyboard layout and currently have to use quick hack/patch below to easily use Left bracket and Right bracket.

Would it be hard to implement keymaps for submenus like these?

--- a/helix-term/src/keymap/default.rs
+++ b/helix-term/src/keymap/default.rs
@@ -104,7 +104,7 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
             "a" => select_textobject_around,
             "i" => select_textobject_inner,
         },
-        "[" => { "Left bracket"
+        "[" | "ü" => { "Left bracket" // better support for German keyboard
             "d" => goto_prev_diag,
             "D" => goto_first_diag,
             "g" => goto_prev_change,
@@ -117,7 +117,7 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
             "p" => goto_prev_paragraph,
             "space" => add_newline_above,
         },
-        "]" => { "Right bracket"
+        "]" | "+" => { "Right bracket" // better support for German keyboard
             "d" => goto_next_diag,
             "D" => goto_last_diag,
             "g" => goto_next_change,
@markus-oberhumer markus-oberhumer added the C-enhancement Category: Improvements label Mar 13, 2024
@markus-oberhumer markus-oberhumer changed the title Better support for internation keyboards Better support for international keyboards Mar 13, 2024
@TornaxO7
Copy link
Contributor

TornaxO7 commented Mar 13, 2024

Hi! May I suggest you to try NeoQwertz? You won't have to relearn QWERTZ but you can access all special characters (brackets, backticks, etc.) easier through it. I can highly recommend it.

Otherwise I'd suggest to remap your the keybindings because adding default international keybindings doesn't sound easy to maintain in my opinion.

@pascalkuthe
Copy link
Member

This can be handled by a simple remap with3 lines in your config. No need to change the default keymap.

I am also german and I would also recommend to save your hands and switch to a better keyboard layout. QWERTZ somehow manages to be significantly worse than QWERTY (which is itself not a good layout).

@pascalkuthe pascalkuthe closed this as not planned Won't fix, can't repro, duplicate, stale Mar 13, 2024
@markus-oberhumer
Copy link
Author

This can be handled by a simple remap with3 lines in your config. No need to change the default keymap.

Nice, but how can I change this? In vim/neovim I'm using

nmap ü [
nmap + ]

but in helix something like this is invalid:

[keys.normal]
"ü" = "["

@sicher
Copy link

sicher commented Mar 13, 2024

This can be handled by a simple remap with3 lines in your config. No need to change the default keymap.

Nice, but how can I change this? In vim/neovim I'm using

nmap ü [
nmap + ]

but in helix something like this is invalid:

[keys.normal]
"ü" = "["

https://docs.helix-editor.com/remapping.html

@markus-oberhumer
Copy link
Author

markus-oberhumer commented Mar 13, 2024

@sicher Thanks, but I did read the docs (and even had a glimpse at the Rust source code).

So please show me the actual lines for config.toml.

@TornaxO7
Copy link
Contributor

@markus-oberhumer
I think you can't just remap a key to imitate another key. Have you tried

[keys.normal.ü]
"d" = "goto_prev_diag"
"D" = "goto_first_diag"
"g" = "goto_prev_change"

for example?

@markus-oberhumer
Copy link
Author

@TornaxO7 The point of this issue is that I want to remap ü to the "Left bracket submenu".

@sicher
Copy link

sicher commented Mar 13, 2024

@TornaxO7 The point of this issue is that I want to remap ü to the "Left bracket submenu".

That's not possible atm. You have to create a new, or overwrite the bindings for a minor mode. Like in the docs.

@markus-oberhumer
Copy link
Author

Well, that why my OT says:

Would it be hard to implement keymaps for submenus like these?

@sicher
Copy link

sicher commented Mar 13, 2024

Well, that why my OT says:

Would it be hard to implement keymaps for submenus like these?

Your example code showed a hard-coded solution for your specific keyboard. That's very easy to do (you did it), but it would not help me at all on my Swedish keyboard.

There are a few open PR:s that may be relevant. Check out #5046 for instance.

@markus-oberhumer
Copy link
Author

@sicher @pascalkuthe My example code is explicitly annotated as quick hack/patch to show the work-around I'm currently using because of what I think is a missing keymap feature.

(NOTE to self: don't include patches unless necessary)

@sicher
Copy link

sicher commented Mar 13, 2024

@sicher @pascalkuthe My example code is explicitly annotated as quick hack/patch to show the work-around I'm currently using because of what I think is a missing keymap feature.

There are PR:s that intend to address remapping. I linked to one above.

(Edit: Or perhaps there's just that single one. I dunno - haven't dug through all open PR:s)

@markus-oberhumer
Copy link
Author

@sicher #5046 looks like something different (a complete keyboard remap, which is not what I suggested. I don't want to transform ü to [ while in insert mode...)

@sicher
Copy link

sicher commented Mar 13, 2024

@sicher #5046 looks like something different (a complete keyboard remap, which is not what I suggested. I don't want to transform ü to [ while in insert mode...)

I might misunderstand that PR totally, but one example given seems to me like exactly what you're after:

[[editor.layout-remap]]
from = 'э'
into = "'"

EDIT: For your case that would be (I guess):

[[editor.layout-remap]]
from = 'ü'
into = "["

EDIT 2: And, your point about insert mode is explicitly addressed in the PR description:

These translation mappings are applied in every mode except for (obviously) the Insert mode.

@markus-oberhumer
Copy link
Author

Well, I'd guess the correct way to tackle this is to introduce something like a left_bracket_menu command which then can get mapped in [keys.normal].

@markus-oberhumer
Copy link
Author

@pascalkuthe As you have closed this issue: I'd still like to see your config.toml changes for simple remap with3 lines in your config.

Maybe I'm missing something here.

@the-mikedavis
Copy link
Member

Easier remapping of minor modes like [/] is #5734

The current way to remap this is:

# config.toml
[keys.normal."ü"]
d = "goto_prev_diag"
D = "goto_first_diag"
g = "goto_prev_change"
G = "goto_first_change"
f = "goto_prev_function"
t = "goto_prev_class"
a = "goto_prev_parameter"
c = "goto_prev_comment"
T = "goto_prev_test"
p = "goto_prev_paragraph"
space = "add_newline_above"

[keys.normal."+"]
d = "goto_next_diag"
D = "goto_last_diag"
g = "goto_next_change"
G = "goto_last_change"
f = "goto_next_function"
t = "goto_next_class"
a = "goto_next_parameter"
c = "goto_next_comment"
T = "goto_next_test"
p = "goto_next_paragraph"
space = "add_newline_below"

@markus-oberhumer
Copy link
Author

@the-mikedavis Many thanks for that info, this is at least a workaround I can live with for now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

5 participants