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

Neovim not working as expected #6425

Open
lemurianredmage opened this issue Nov 21, 2024 · 7 comments
Open

Neovim not working as expected #6425

lemurianredmage opened this issue Nov 21, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@lemurianredmage
Copy link

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20240203-110809-5046fc22

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Current behavior
When i open neovim in wezterm, the Insert key is not working, not switching between modes. Also, if i press any other character, it automatically switches to insert mode and i can start typing.

Correct behavior
I have iterm and when i open neovim on it, if i press the insert key, then it switches between modes, and if i am in normal mode and i type any other character, i cannot start typing unless i am on insert mode from the Insert key.

To Reproduce

For Insert key issue

  • Open wezterm
  • Open neovim
  • Neovim should be in normla mode
  • Press Insert Key
  • Nothing happens.

For any other character issue

  • Open wezterm
  • Open neovim
  • Neovim should be in normla mode
  • Press any character. 'a' for example
  • It automatically switches to insert mode and i can start typing.

Configuration

no config

Expected Behavior

For Insert key issue

  • Open wezterm
  • Open neovim
  • Neovim should be in normla mode
  • Press Insert Key
  • It should switch between modes.

For any other character issue

  • Open wezterm
  • Open neovim
  • Neovim should be in normla mode
  • Press any character. 'a' for example
  • It should not switch modes and should not allow me to type, unless another mode was already set by the insert key.

Logs

Logs for insert key

09:33:43.405  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: true, handled: Handled(false) }
09:33:43.407  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
09:33:43.407  INFO   wezterm_gui::termwindow::keyevent     > send to pane DOWN key=Char('\u{f746}') mods=NONE
09:33:43.407  INFO   wezterm_term::terminalstate::keyboard > key_down: sending "\u{f746}", Char('\u{f746}') NONE
09:33:43.502  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: false, handled: Handled(false) }
09:33:43.503  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
09:33:43.503  INFO   wezterm_gui::termwindow::keyevent     > send to pane UP key=Char('\u{f746}') mods=NONE

Logs for 'a' key

09:34:30.366  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Char('a'), modifiers: NONE, leds: (empty), phys_code: Some(A), raw_code: 0, repeat_count: 1, key_is_down: true, handled: Handled(false) }
09:34:30.367  INFO   wezterm_gui::termwindow               > DeadKeyStatus now: None
09:34:30.367  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('a'), modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: true, raw: None }
09:34:30.367  INFO   wezterm_gui::termwindow::keyevent     > send to pane DOWN key=Char('a') mods=NONE
09:34:30.367  INFO   wezterm_term::terminalstate::keyboard > key_down: sending "a", Char('a') NONE
09:34:30.367  INFO   wezterm_gui::termwindow               > DeadKeyStatus now: None
09:34:30.543  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Char('a'), modifiers: NONE, leds: (empty), phys_code: Some(A), raw_code: 0, repeat_count: 1, key_is_down: false, handled: Handled(false) }
09:34:30.543  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('a'), modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Char('a'), modifiers: NONE, leds: (empty), phys_code: Some(A), raw_code: 0, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
09:34:30.543  INFO   wezterm_gui::termwindow::keyevent     > send to pane UP key=Char('a') mods=NONE

Anything else?

No response

@lemurianredmage lemurianredmage added the bug Something isn't working label Nov 21, 2024
@bew
Copy link
Contributor

bew commented Nov 22, 2024

Maybe it because the insert key isn't bound by default in neovim to enter insert mode (but the a key (like the i key) is).

Have you tried another terminal before saying it's an issue with wezterm?

@lemurianredmage
Copy link
Author

Maybe it because the insert key isn't bound by default in neovim to enter insert mode (but the a key (like the i key) is).

Have you tried another terminal before saying it's an issue with wezterm?

yes i have, in the describe bug section it says that in iTerm is working as expected

@bew
Copy link
Contributor

bew commented Nov 22, 2024

Oh yes sorry I didn't see it.

I just tested on a Linux system and it indeed works as you'd expect, and neovim detects the key as <Insert>.

Can you try in neovim (in command or insert mode) with Ctrl-v (not cmd-v) followed by the insert key?
Neovim should print you what it understood of the key, does it also give you <Insert> ?
If it does, you could check if your distribution has a disabling mapping for it using :nmap <Insert>

@lemurianredmage
Copy link
Author

Oh yes sorry I didn't see it.

I just tested on a Linux system and it indeed works as you'd expect, and neovim detects the key as <Insert>.

Can you try in neovim (in command or insert mode) with Ctrl-v (not cmd-v) followed by the insert key? Neovim should print you what it understood of the key, does it also give you <Insert> ? If it does, you could check if your distribution has a disabling mapping for it using :nmap <Insert>

If i try Ctrl-v and then press Insert Key it switches to Visual Block.
if i run :nmap <Insert> it tells me no mapping found

@bew
Copy link
Contributor

bew commented Nov 22, 2024

If i try Ctrl-v and then press Insert Key it switches to Visual Block.

This is very weird..

Logs for insert key

09:33:43.405  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: true, handled: Handled(false) }
09:33:43.407  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
09:33:43.407  INFO   wezterm_gui::termwindow::keyevent     > send to pane DOWN key=Char('\u{f746}') mods=NONE
09:33:43.407  INFO   wezterm_term::terminalstate::keyboard > key_down: sending "\u{f746}", Char('\u{f746}') NONE
09:33:43.502  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: false, handled: Handled(false) }
09:33:43.503  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Char('\u{f746}'), modifiers: NONE, leds: (empty), phys_code: Some(Help), raw_code: 114, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
09:33:43.503  INFO   wezterm_gui::termwindow::keyevent     > send to pane UP key=Char('\u{f746}') mods=NONE

From these logs, it's not actually the Insert that is detected by the terminal, it's instead detecting some other key that is not standard (see https://www.compart.com/en/unicode/U+F746 it's in the private area of unicode), in the key event we can see it's detected as phys_code: Some(Help), some help key 🤔

I'm guessing this is MacOS-specific stuff, where the OS hijacks the usual Insert key on standard keyboards to do something else instead (probably showing some help in more traditional MacOS apps?).

I'm not sure how iterm2 does interprets it as an actual insert key, 'cause the OS tells us it's not.
Have you tried it in other cross-platform terminals like Alacritty or Kitty ?

@lemurianredmage
Copy link
Author

I just tried both kitty and alacritty and it works just fine.

@lemurianredmage
Copy link
Author

lemurianredmage commented Nov 22, 2024

i Jus try this configuration in the .wezterm.lua and it solves the issue with the insert key. But i do not know if this is intended.

{
      key = '\u{f746}', -- Match the logged value
      mods = "NONE",
      action = wezterm.action.SendKey { key = "Insert" },
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants