nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.56k stars 1.73k forks source link

fish vendor completions #5119

Open paholg opened 5 months ago

paholg commented 5 months ago

Description

Right now, we generate fish completions from man-pages, which works well. However, some programs include their own completion definitions that are better than the generated ones, and these are not used by fish.

For example, in zsh.nix, we add various locations to fpath: https://github.com/nix-community/home-manager/blob/36f873dfc8e2b6b89936ff3e2b74803d50447e0a/modules/programs/zsh.nix#L559-L561

If I look in /etc/profiles/per-user/paho/share/zsh/site-functions, I see definitions for various packages I have installed, and zsh is able to use them for completions.

However, we don't seem to do anything similar for fish.

I suspect this is an easy fix; I do have the directory /nix/store/8js1fw8jwj9f1l2r7jlfbcx2k3vzi42k-home-manager-path/share/fish/vendor_completions.d populated with the desired completions, and if I run

set fish_complete_path /nix/store/8js1fw8jwj9f1l2r7jlfbcx2k3vzi42k-home-manager-path/share/fish/vendor_completions.d/ $fish_complete_path

then they are used. However, I am not sure the correct way to specify this in fish.nix. I think part of my confusion is that we also have functions and completions symlinks there (which work in fish), but none of those end up in my config directory or config file.

leana8959 commented 5 months ago

I have found a simple solution to this.

In this section of the automatic completion generation from man-pages: https://github.com/nix-community/home-manager/blob/c0ef0dab55611c676ad7539bf4e41b3ec6fa87d2/modules/programs/fish.nix#L421-L430

We could add a line right after line 428, like this:

find $src -path "*/share/fish/vendor_completions.d/*.fish" | xargs -I {} cp {} $out

This would essentially overwrite the automatically generated completions by vendor provided ones. I have thought about the case where the user might want to opt for the generated completions for some reason, should this be guarded behind an option ?

Hope this helps ! If this resembles to a good solution, I might open a PR addressing this issue.

Update:

I think my previous solution was fundamentally flawed, I managed to add the path paholg mentioned to fish_completion_path, I opened a PR for that.

drupol commented 4 months ago

Fish also includes Python3 by default, making the closure size to 220M (way too big for a shell). I believe we can do better, see this thread: https://github.com/NixOS/nixpkgs/pull/304313

stale[bot] commented 1 month ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.