omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

SUPER+C (universal copy) does nothing for a keyboard-made TUI selection under foot (e.g. Neovim visual mode)

Open WonkaRed opened this issue 2 months ago • 3 comments

System details

Omarchy 4.0.3-1 foot 1.28.0 (default terminal)

What's wrong?

SUPER+C (universal copy) does nothing when the active selection is a keyboard-made selection inside a TUI application such as Neovim. No error, no clipboard change, no feedback.

Mechanism

SUPER+C is bound in default/hypr/bindings/clipboard.lua. For windows tagged terminal, it sends Ctrl+Insert instead of Ctrl+C (the universal_clipboard_shortcut branch, since Ctrl+C would send SIGINT to a foreground process):

o.bind("SUPER + C", "Universal copy", universal_clipboard_shortcut("CTRL", "C", "CTRL", "Insert"))

foot is the default terminal, and its stock config binds:

[key-bindings]
clipboard-copy=Control+Insert Control+Shift+c XF86Copy

Per man 5 foot.ini, clipboard-copy "Copies the current selection into the clipboard" — this is foot's own terminal-grid selection (a mouse drag over the cell grid), not anything the child process reports.

A Neovim visual-mode selection (v/V, made with the keyboard) lives entirely inside Neovim's own buffer state. It is not a foot grid selection, so when foot receives Ctrl+Insert it finds no grid selection and silently does nothing.

Because foot also consumes Ctrl+Insert as a bound key, the keystroke is never forwarded to the child process either. So Neovim (or any other TUI that manages its own selection: Helix, less, tmux copy-mode) has no way to see the keypress and handle it itself. SUPER+C is a dead end for any keyboard-made TUI selection under foot.

Paste is unaffected: clipboard-paste (Shift+Insert) is unconditional in foot and works regardless of selection state, and bracketed paste delivers it to the child normally.

This is scoped to the SUPER+C chord specifically, not clipboard integration in general. Yanks already reach the system clipboard for editors that set clipboard=unnamedplus with wl-clipboard present (e.g. plain y in Neovim), so y already works as a workaround.

Steps to reproduce

  1. Open foot (the default terminal).
  2. Run nvim somefile.md.
  3. Select a few lines in visual mode with V.
  4. Press SUPER+C.
  5. Run wl-paste (or paste with SUPER+V into another window): the clipboard is unchanged from before step 4.

What I expected

SUPER+C to copy the Neovim visual selection to the system clipboard, the way it copies a selection in GUI apps.

Note on possible fixes

I want to flag that the fix here isn't obvious, rather than propose one. foot intercepting Ctrl+Insert for its own grid-selection copy is exactly what lets SUPER+C work for a mouse selection in foot today (e.g. selecting text in less or plain shell output). Freeing Ctrl+Insert in foot's default config so it reaches the child process would let TUIs implement their own handler (as Neovim already does for other CSI-u sequences in this same config), but it would also disable the existing mouse-selection copy path in foot itself unless something else picks it up. Whether that tradeoff is worth it, or whether there's a better way to have foot fall back to forwarding the key when it has no grid selection, seems like a maintainer call rather than something to prescribe here.

Related prior history

For context: #5251 / discussion #6296 covered a similar-sounding SUPER+C-in-Neovim complaint on Omarchy 3.5.0, but for kitty/alacritty/ghostty (foot was not the default terminal at that point and isn't mentioned there). The attempted fix, PR #5258, removed the Ctrl+Insert interception from kitty/alacritty and added a Neovim <C-Insert> keymap, but it was closed without merging (a commenter reported it still didn't work reliably on ghostty), and no equivalent change ever landed for foot's config. I don't believe this is a duplicate of that thread since it's a different terminal, a different Omarchy version, and the underlying interception point (foot's own clipboard-copy binding) is different from what that PR touched, but it's the same class of problem and worth having in view.

Diagnostics

$ omarchy version
4.0.3-1

$ foot --version
foot version: 1.28.0 (Sep 03 2026, branch 'makepkg') +pgo +ime +graphemes +toplevel-tag +blur -assertions

WonkaRed avatar Sep 21 '26 18:09 WonkaRed

Reproduced on a clean Omarchy 4.0.4 worker (foot 1.28.0, Neovim 0.12.5, Hyprland 0.56.2), and the mechanism is as you describe. With two lines selected in Neovim visual-line mode, sending the exact chord the universal-copy binding sends to a terminal-tagged window left the clipboard unchanged and Neovim still in visual mode. That held both for the 4.0.3 chord (Ctrl+Insert) and for the one current quattro sends (Ctrl+Shift+C, default/hypr/bindings/clipboard.lua:46). foot binds both to clipboard-copy (config/foot/foot.ini:18) and consumes the key even when it has no grid selection. As a control, starting foot with clipboard-copy unbound and giving Neovim a visual-mode mapping of the same chord to "+y made the selection reach the clipboard. So the chord does arrive whenever foot does not take it, and foot is the only thing in the way.

It is not specific to foot. kitty, Alacritty and Ghostty also bind both chords to their own grid-selection copy (etc/xdg/kitty/kitty.conf:14, config/alacritty/alacritty.toml:23, config/ghostty/config:27, plus each one's built-in Ctrl+Shift+C). Nothing in this repository maps either chord to a copy inside Neovim. One correction to the note on fixes: unbinding only the chord SUPER+C sends would leave foot's other copy keys (Ctrl+Insert or Ctrl+Shift+C, and XF86Copy) working for mouse selections. What it would remove is SUPER+C as a way to copy them.

No fix has been drafted, because every fix chooses a behaviour rather than correcting a defect. Options include: forwarding the chord when the terminal has no selection (kitty's copy_or_noop and Ghostty's performable: bindings can express this; foot has no equivalent that I could establish); having the application map the chord itself; or deciding which selection wins when both exist. #14674 and #13349, and PR #14766, are related but different: they are about whether the chord matches foot's binding at all, and once it does, it is still consumed the same way here.

Second opinion from Codex Medium. It agreed with the mechanism, which was already written down when it reviewed, so its independence is not guaranteed. It added the cross-terminal comparison and the copy_or_noop / performable: options above. This now waits on the maintainer to decide which behaviour SUPER+C should have inside a TUI.

omarchybot avatar Oct 12 '26 11:10 omarchybot

TL;DR - LLM assisted workaround

omarchy-copy-4.0.4.sh omarchy-copy-master.sh omarchy-copy-herdr.sh

SUPER+C copies nothing from a Neovim mouse selection because the terminal consumes the copy key before Neovim sees it. The fix is a small script bound to SUPER+C, plus two lines in Neovim. When Neovim is in the foreground, the script sends Ctrl+Alt+Insert, which no terminal binds, and Neovim copies on that key. It works in kitty, foot, Alacritty and Ghostty when Neovim runs directly in the terminal. A variant that also handles herdr works there too. tmux and other multiplexers are not supported. Three script files are attached: one for Omarchy 4.0.4, one for unreleased builds, and one for 4.0.4 with herdr support.

Why it fails

SUPER+C sends a copy chord to terminal windows: Ctrl+Insert on 4.0.4, and Ctrl+Shift+C on the unreleased master and quattro branches. All four terminals bind both chords to their own copy. With Neovim's mouse mode on, a drag selects inside Neovim, so the terminal has no selection. The terminal still consumes the key.

In a control test, Ctrl+Insert was consumed by all four terminals. Ctrl+Shift+C was consumed by kitty, foot and Alacritty, and passed through in Ghostty.

Foot cannot be configured around it. In input.c (commit cb27717), BIND_ACTION_CLIPBOARD_COPY calls selection_to_clipboard() and returns true even with no selection. BIND_ACTION_NOOP also returns true.

The fix

  1. Download the script for your version. Use omarchy-copy-4.0.4.sh for the stable release (4.0.4-1 is the newest as of 2026-10-17). Use omarchy-copy-master.sh for unreleased master and quattro builds. They differ only in the terminal chord. If you run herdr, use omarchy-copy-herdr.sh, which is the 4.0.4 file plus herdr support. Save it as ~/.local/bin/omarchy-copy and run chmod +x on it.
  2. In ~/.config/hypr/bindings.lua:
    hl.unbind("SUPER + C")
    o.bind("SUPER + C", "Universal copy", os.getenv("HOME") .. "/.local/bin/omarchy-copy")
    
  3. In your Neovim config:
    vim.keymap.set("v", "<C-M-Insert>", '"+y', { desc = "Copy selection to system clipboard" })
    vim.keymap.set("n", "<C-M-Insert>", '"+yy', { desc = "Copy line to system clipboard" })
    

Everywhere else the script sends what your Omarchy version sends. Super+V and Super+X stay stock. The script holds an editable list of programs, copy_aware_apps=(nvim). To cover another program, add its name and map Ctrl+Alt+Insert in that program. Only Neovim was tested.

Why Ctrl+Alt+Insert? Chord test results

The chord has to be unbound in every terminal, reach the program as a distinct key, and work for programs that do not use the newer keyboard protocol. I sent each chord to Neovim in visual mode in each terminal:

Chord kitty foot Alacritty Ghostty
Ctrl+Shift+C consumed consumed consumed reached Neovim
Ctrl+Alt+C reached Neovim reached Neovim reached Neovim reached Neovim
Ctrl+Shift+Alt+C reached Neovim reached Neovim reached Neovim reached Neovim
Ctrl+Alt+Insert copied copied copied copied

Ctrl+Alt+Insert is the safe choice for a list of unknown programs. Ctrl+Alt+C and Ctrl+Shift+Alt+C also work in newer programs. All four terminals support the kitty keyboard protocol, and Neovim 0.12.5 asked for it, so it received each chord as its own key. A program that does not ask for the protocol gets the classic encoding, where Ctrl+Alt+C is ESC followed by Ctrl+C. Ctrl+Alt+Insert has its own sequence in both encodings (ESC [ 2 ; 7 ~).

If you only use programs that enable the protocol, you can use a C chord instead. Change the chord in the script and in the program's mapping.

Tested

Omarchy 4.0.4-1, Hyprland 0.56.2, Neovim 0.12.5 (LazyVim), foot 1.28.0, kitty 0.48.2, Alacritty 0.17.0, Ghostty 1.3.1.

  • All three attached files copied the selection in all four terminals with Neovim running directly in the terminal.
  • The herdr file also copied it from a Neovim pane inside herdr 0.9.5 in all four terminals, with the mouse. In a herdr pane running a plain shell it falls back to the stock chord.
  • Real SUPER+C presses with Super held also copied the right text in each terminal. Each test window held different text, and each paste carried only its own two selected lines. Those presses used the Ctrl+Alt+Insert path, which is identical in both files.
  • The selections were made with the keyboard, not a mouse drag.
  • A normal window gets Ctrl+C. A terminal without Neovim gets Ctrl+Insert (4.0.4 file) or Ctrl+Shift+C (master file). I checked this by watching the chord the script sends.

Limits

Not supported

  • Only programs named in copy_aware_apps are detected, and each needs its own mapping for the chord. Only Neovim was tested.
  • The herdr file needs herdr on your PATH and a herdr client running directly in the terminal. It does not handle --remote clients.
Other terminal multiplexers (tmux, zellij, screen) and ssh

Neovim inside tmux is not detected. The 4.0.4 and master files copied nothing inside herdr or inside a fresh tmux server, in all four terminals. In each case the terminal's foreground program is the multiplexer, not Neovim. Only the herdr file handles herdr. A chain of foot, herdr, tmux and Neovim also failed. Neovim over ssh fails for the same reason.

Supporting each other multiplexer needs separate, more complex work: tmux, zellij, screen and others. The script would have to ask the multiplexer which pane is active and what runs in it, then send the chord to that pane with the multiplexer's own command. The herdr file does this for herdr. For tmux, the manual documents list-clients, pane_current_command and send-keys -H, which should be enough. I did not build or test that. I did not investigate zellij or screen.

Not tested

  • Plain terminal copy with a real selection and key press. Only the chord the script sends was checked.
  • A terminal that runs all windows in one process might report Neovim from a sibling window. Two Ghostty windows started from a shell were separate processes. Ghostty's single-instance mode and foot's server mode were not tested.
  • The master file on an Omarchy build that sends Ctrl+Shift+C itself, because none is released. There is no herdr variant for master builds. Change the terminal chord line in the herdr file to match the master file.
  • A built-in fix would put the same check in universal_clipboard_shortcut in default/hypr/bindings/clipboard.lua. I did not port or test that.

Conflicts and risks

  • Ctrl+Alt+Insert is unclaimed on stock Omarchy, but VMware, some remote desktop clients and IntelliJ use it. They never receive it, because the script sends it only to a terminal with Neovim in the foreground. Check your own bindings with hyprctl binds | grep -i "key: Insert". No output means no Insert binding.
  • A foot config from before the Ctrl+Shift+C change binds only Control+Insert (#13349). Plain terminal copy would fail there with the master file, so use the 4.0.4 file.

ntwest avatar Oct 17 '26 18:10 ntwest

Another affected app: TTT, a terminal text editor with its own mouse and keyboard selection. Same mechanism as above: Super+C reaches foot as Ctrl+Insert, foot consumes it with no grid selection, and TTT never sees the key. TTT's own copy (Ctrl+C) works and already writes to the system clipboard.

A simpler workaround for apps that already use Ctrl+C as copy: launch them under an app-id that doesn't match the terminal tag rule, so universal copy sends plain Ctrl+C:

foot --app-id=ttt -e ttt

Confirmed working for TTT. This only fits apps where Ctrl+C means copy (not Neovim), but it suggests a per-app opt-out would cover this class of app. #13559 adds a similar per-window opt-out for Emacs.

millsaj avatar Oct 23 '26 11:10 millsaj