wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Issue with Ctrl + Space not working properly

Open sebiwi opened this issue 1 year ago • 3 comments

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

macOS

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

Aerospace

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?

No, and I'll explain why below

Describe the bug

I use Vim with Coc, and when I tap ctrl-space it triggers auto completion](https://github.com/sebiwi/dotfiles/blob/master/vim/plugin-settings/coc.vim#L58).

When I try to trigger the auto-completion on wezterm, I re-insert the last inserted text instead. There are no other mappings for or <ctrl-@> on vim>:

:verbose imap <c-@>
Seen modifyOtherKeys: true
Kitty keyboard protocol: Cleared
i  <C-@>       * coc#refresh()

This works perfectly on iterm2 without any extra configuration. This also works on wezterm if I use a different trigger sequence (e.g. ctrl-d).

To Reproduce

  • Install vim with coc on MacOs.
  • Use the example configuration for coc.
  • Open vim in wezterm.
  • Go into insert mode, and try to trigger autocompletion using

Configuration

local wezterm = require("wezterm")

local config = wezterm.config_builder()

config.font = wezterm.font("MesloLGS Nerd Font Mono") config.font_size = 14

config.enable_tab_bar = false config.window_decorations = "RESIZE"

config.color_scheme = 'Solarized (dark) (terminal.sexy)'

config.window_background_opacity = 0.8 config.macos_window_background_blur = 10

config.audible_bell = "Disabled" config.native_macos_fullscreen_mode = true

return config

Expected Behavior

Auto-completion is triggered on vim.

Logs

No logs.

Anything else?

No response

sebiwi avatar Aug 26 '24 15:08 sebiwi

Hi Sebiwi,

What sequence of characters is being generated when you press ctrl-space in Wezterm? It sounds like wezterm is not generating <C-@>, so it would probably be illuminating to know what characters are actually being generated instead.

loops avatar Aug 28 '24 04:08 loops

Hey @loops,

I didn't really know how to check this. I'm using the Ctrl-V shortcut in Vim, which seems to do what you want:

CTRL-V          Insert next non-digit literally.  For special keys, the
                terminal code is inserted.  It's also possible to enter the
                decimal, octal or hexadecimal value of a character
                i_CTRL-V_digit.
                The characters typed right after CTRL-V are not considered for
                mapping.  {Vi: no decimal byte entry}
                Note: When CTRL-V is mapped (e.g., to paste text) you can
                often use CTRL-Q instead i_CTRL-Q.

When I type Ctrl-V, then Ctrl-space in Vim, I get the ^@ character, which is theoretically the right value. Nevertheless, the autocomplete feature is still not triggered.

For reminders, this exact same configuration works with iTerm2 with the default configuration. Other key-mappings for the same feature (e.g. ctrl-;) work, and there are no other mappings for Ctrl-space in Vim nor in wezterm.

Thanks for your help.

sebiwi avatar Aug 28 '24 08:08 sebiwi

It sounds like Wezterm is behaving properly and generating the correct sequence. Perhaps Vim is behaving differently based on the terminal type? Depending on your setup, the TERM environment variable may be set to "wezterm", and that might affect how Vim is behaving.

One thing you could try, is to temporarily disable a few of the keyboard options in your Wezterm config file:

config.use_dead_keys = false config.use_ime = false

Just to see if they have any effect.

Also, from inside wezterm at the command prompt, you can type:

wezterm show-keys --lua

To see a list of keyboard mappings that Wezterm is currently applying. It might reveal something in the config that is causing a problem for you.

Oh, another config option you might temporarily try is:

config.disable_default_key_bindings = true

To see if that changes the symptoms you're seeing, although it will make wezterm hard to use.

Hope you're able to find something. I'm not on macos myself, so these are really just general ideas, maybe someone else will be able to identify the issue more directly.

loops avatar Aug 28 '24 16:08 loops

Thanks for your input! I tried all the things you mentioned and nothing solved the issue.

sebiwi avatar Aug 29 '24 07:08 sebiwi

Same problem when using it on Windows 11 as well.

souradeep100 avatar Dec 02 '24 13:12 souradeep100

Are you ^Space is nowhere mapped on your system? On macOS it's often used for keyboard input source selection, and can conflict with other apps.

b4nst avatar Dec 23 '24 10:12 b4nst

Hello, I (seriously) migrated to nvim because of this. I'm not encountering the error in nvim anymore, so I guess I'll close this.

Thanks!

sebiwi avatar Dec 23 '24 14:12 sebiwi

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Jan 23 '25 03:01 github-actions[bot]