carapace-sh / carapace-bin

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

fish vs carapace in 2024 #2518

Open ccoVeille opened 2 months ago

ccoVeille commented 2 months ago

Request

I'm a fish user, and I'm new to caparace

I followed the step describe in https://carapace-sh.github.io/carapace-bin/setup.html

I was surprised to see

carapace --list | awk '{print $1}' | xargs -I{} touch ~/.config/fish/completions/{}.fish # disable auto-loaded completions (#185)

see

I can see the reference here https://github.com/carapace-sh/carapace-bin/blob/1b1ecb18cac516d0e68ec373da718e14faf9315f/docs/src/setup.md?plain=1#L32

I found the code was moved via 6ad36ab6bdaabcea04b7e2c2dd244c888063b0b0 and was initially added via 79e988ed8c311b63b2fa62ba36849dd25ae2bb68 (via #880)

All these are pretty old, the #185 was mentioning

Is there any progress around this ?

I saw the status of fish-shell#6716 but I was curious if there is nothing else that evolved in the last few years. I find pretty painful to create empty file it's a strange logic

I found this https://github.com/cli/cli/issues/360#issuecomment-849593706

Proposed solution

I would have expected carapace to:

they could contain comment about why the file is there and empty

for example

~/.config/fish/completions/git.fish could contain this

complete -e 'git' 
complete -c 'git' -f -a '(_carapace_lazy git)'

Anything else?

I might be wrong about the things I'm asking or the point I'm raising, but I would like to know if we couldn't do something better for the fish integration

Thanks

Polar

Fund with Polar

rsteube commented 2 months ago

Well it is only a workaround and I expected fish to fix this fairly quickly (little did I know).

The problem is that this is a bug in fish and from the outside this was the only way to get around it. Erasing existing completion doesn't work, because fish loads the system completion on first invocation (pressing tab). It does so even if one is already defined which clutters it.

Shell startup time is critical which limits other potential workarounds.

Generating the files in go is possible, but it is quite an invasive step as it essentially kills the native completion of fish which might be unwarranted when one disables a completer from carapace.

To be honest, this just needs to be fixed in fish with the tombstone approach mentioned here.

ccoVeille commented 2 months ago

Thanks for your reply. I understand.

Do you think I could quote your reply in the involved fish discussions, and ask them for a status?

rsteube commented 2 months ago

Sure

ccoVeille commented 2 months ago

A fix was provided. Let now wait for it to be released

azlekov commented 2 weeks ago

Hello carapace is adding like 3 seconds to my fish prompt startup and I think is because of these completions. Is there any fix for this?

rsteube commented 2 weeks ago

Hello carapace is adding like 3 seconds to my fish prompt startup and I think is because of these completions. Is there any fix for this?

Even with the workaround it shouldn't be this bad :thinking:. The files in ~/.config/fish/completions just need to be created once for each new completer. So the workaround doesn't need to be executed every time.

The complete command in fish also tends to be quite slow (which is a bit weird), if you want the full startup speed you could also export the scripts instead of sourcing carapace.

carapace git fish > ~/.config/fish/completions/git.fish

But you'd need to update PATH and add the set-env/get-env functions manually.

ccoVeille commented 2 weeks ago

The point raised by @azlekov is legitimate, and the workrounds you provided could provide a solution.

But @rsteube said a few months ago fish needed to change something in a way to use something called "tombstone"

But the issue is now fixed

https://github.com/fish-shell/fish-shell/commit/5918bca1eba861e3e8f69f055aac20e9cae1af3c

Shouldn't the solution be now updated as fish should support it.

Please note, I'm aware there is no new fish release since March 2024

rsteube commented 2 weeks ago

Well, depends on how easy it is to install a nightly (and how stable the master is). But I can add a notice to the instructions, yes.

Might slowly be time to have another look at this. Invocation delay of carapace is in the range of 7-10ms, which I personally don't consider an issue. But the slow performance of the complete command and the amount of completers registered due to the bridges makes the whole topic relevant again.

It's possible to have a near zero overhead for most shells, but it involves a slightly different approach (see above).