WSL port 2/7: give unnamedplus something to point at on WSL

Merged
JA
3mo ago
+170-5

Stacked on #7.

Clipboard

clipboard=unnamedplus names a register, not a provider. Nvim finds the
provider itself nearly everywhere — pbcopy/pbpaste on macOS,
wl-copy/xclip/xsel/win32yank on Linux, and WSLg hands you wl-copy and
xclip already wired to the Windows clipboard. On a Mac and on a normal WSL
box this new block does nothing at all.

It exists for the box where that probe comes up empty — WSL with no WSLg, no X,
no win32yank. There, unnamedplus does not fail loudly:

  • Ctrl+C copies nothing
  • Ctrl+V pastes nothing
  • Ctrl+V over a selection deletes the selection and puts nothing back
  • and clipboard: No provider waits as a hit-enter prompt, in an editor whose
    whole premise is that you never stop typing

clip.exe + powershell.exe are the pair still present when interop is on but
no display is.

Two deliberate choices:

  • paste is a Lua function, not a plain command, because Get-Clipboard
    returns CRLF and nvim splits on \n only — every pasted line would keep a
    literal \r, and nothing built in strips it.
  • cache_enabled = 0 — a cache that answers with what you last copied
    would silently ignore anything copied in a browser, which is most of what this
    register is for. The cost is a ~0.4s round trip per paste, on this path only.

Which python3

WSL appends the Windows PATH, so on a box with no Linux python installed
python3 resolves to the Store App Execution Alias under WindowsApps — a stub
that opens the Microsoft Store instead of running your file. It would do that
inside a 15-row split, leaving Ctrl+R and Ctrl+E looking broken for a reason
nothing on screen explains. Anything under /mnt is a Windows binary, so keep
walking PATH. Everywhere else this stays the literal string python3, so the
generated command is byte-identical to before.

Verification

With every native provider hidden from PATH:

provider: wsl-interop
readback: "alpha\nbravo\n"
has CR: false

With a stub python3 planted under /mnt/c first on PATH, resolution walks past
it to the real interpreter; with a healthy PATH it does not substitute at all.

Full suite on this branch: 526 pass, 0 regressions. Every suite green except
suite_timer (6/36), which fails identically on unmodified main — a
pre-existing Linux bug that checkpoint 3 fixes, not something introduced here.

suiteresult
config invariants84/84
config regressions30/30
mouse, search, autosave, netrw, runwin, quitall green
projects, preload40/40, 26/26
comment toggle ×3 spellings65/65 each
timer6/36 — pre-existing, see checkpoint 3

🤖 Generated with Claude Code

https://claude.ai/code/session_01WveBqAyhoM49p9gWfwBDBx

Summary by CodeRabbit

  • New Features
    • Improved clipboard support in WSL environments, including fallback handling and cleaner pasted text.
    • Added safer Python interpreter detection that avoids Windows Store aliases.
    • Python run and REPL commands now use the detected interpreter and stop gracefully when unavailable.
    • Added warnings when no usable Linux python3 installation is found.

Greptile Summary

The PR adds WSL clipboard-provider detection and Windows interop fallback, while avoiding Windows Store Python aliases.

  • Probes display-backed clipboard providers before retaining them and configures clip.exe/PowerShell when no usable native provider is found.
  • Aligns installer clipboard checks with display requirements and interop availability.
  • Selects a usable Linux Python interpreter for run and REPL commands, disabling those commands with a warning when none exists.

Confidence Score: 4/5

The PR is not yet safe to merge because command-launch failures in the clipboard probe can still suppress the working WSL interop fallback.

When timeout or a paired read-side probe is unavailable, the probe exits with an unrecognized error and display_answers() returns true, retaining a dead native provider instead of activating clip.exe and PowerShell.

Files Needing Attention: nvimrc.lua

Important Files Changed

FilenameOverview
nvimrc.luaAdds WSL detection, native clipboard probing and interop fallback, plus Linux Python resolution; the probe still misclassifies command-launch failures as a live provider.
install.shAligns dependency checks with display-aware clipboard-provider selection and rejects Windows-mounted Python aliases.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Start Neovim on WSL] --> B{Native clipboard candidate?}
  B -- No --> F{clip.exe and PowerShell available?}
  B -- Yes --> C[Run bounded display probe]
  C --> D{Probe classified alive?}
  D -- Yes --> E[Keep native Neovim provider]
  D -- No --> F
  F -- Yes --> G[Configure wsl-interop provider]
  F -- No --> H[Leave provider unavailable]

Reviews (10): Last reviewed commit: "Bound the display probe, and stop readin..." | Re-trigger Greptile