carapace-sh / carapace-bin

multi-shell multi-command argument completer
https://carapace.sh
MIT License
767 stars 45 forks source link

nom-build: zsh bridge does not work #2375

Open Atemu opened 1 month ago

Atemu commented 1 month ago

Current Behavior

Attempting to complete nom-build which ships a zsh-completion in CARAPACE_BRIDGES=zsh nu does not work: NO RECORDS FOUND.

Perhaps this is to do with the completion being equal to some other completion?

Expected Behavior

It should do zsh nix-build completions for nom-build.

Steps To Reproduce

  1. In an env where zsh and nix-output-monitor are installed
  2. Run CARAPACE_BRIDGES=zsh nu
  3. Try to complete nom-build <TAB>

Version

1.0.2

OS

Shell

Anything else?

Nom basically declares itself as an alias. That may be the reason?

Related to this: Should carapace attempt to use its own completions for the command aliased by the bridge or should it use the bridge's aliased command via the bridge too?

Least surprise would probably be to use the aliased command completion via the bridge as command aliases should be handled by carapace itself for native completions.

rsteube commented 1 month ago

Nom basically declares itself as an alias. That may be the reason?

Yeah possibly. Haven't gone too deeply into that edge case.

Apart from that carapace uses a custom config at ~/.config/carapace/bridge/zsh/.zshrc, so if the nom-build completion is registerd in ~/.zshrc that needs to be repeated there.

There's a custom completer for nix-build in carapace. Might be easier to just bridge completions for that one with a spec:

# yaml-language-server: $schema=https://carapace.sh/schemas/command.json
name: nom-build
parsing: disabled
completion:
  positionalany: ["$carapace.bridge.CarapaceBin([nix-build])"]
Atemu commented 1 month ago

Oh so that's what the carapace bridge is for; it struck me as kind of odd.

rsteube commented 1 month ago

Sourcing the users .zshrc can be very slow (depending on whate users put in there) and have some nasty side effects. So I'm kinda forced to use a seperate one. System wide registered completions should work though.

Atemu commented 1 month ago

Ah, sorry I forgot to reply to that part; this is indeed a system-wide completion. It's not at the usual path as I'm on NixOS but the default system zsh is made to discover it just fine.