nix-community / home-manager

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

bug: zsh module - enableAutosuggestions, enableCompletions, and zsh code not working #4917

Open D3vil0p3r opened 5 months ago

D3vil0p3r commented 5 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

If a user creates a ZSH nix file to configure zsh shell by using:

      programs.zsh = {
        enable = true;
        enableAutosuggestions = true;
        enableCompletion = true;
        syntaxHighlighting.enable = true;

        zplug = {
          enable = true;
          plugins = [
            { name = "zsh-users/zsh-autosuggestions"; } # Simple plugin installation
            { name = "zsh-users/zsh-history-substring-search"; } # Simple plugin installation
            { name = "zsh-users/zsh-syntax-highlighting"; } # Simple plugin installation
            { name = "romkatv/powerlevel10k"; tags = [ as:theme depth:1 ]; } # Installations with additional options. For the list of options, please refer to Zplug README.
          ];
        };

Autosuggestions and Completion features don't work correctly, probably because they are not linked to the related .sh files.

Furthermore, if the user tries to insert ZSH code in completionInit or initExtra like:

if [[ $(tty) == */dev/tty* ]]; then
      export PROMPT="%F{46}[HQ:%F{201}$(ip -4 addr | grep -v '127.0.0.1' | grep -v 'secondary' | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | sed -z 's/\n/|/g;s/|\$/\n/' | rev | cut -c 2- | rev) | %n%F{46}]"$'\n'"[>]%F{44}%~ $%f "
else
      export PROMPT="%F{46}β”Œβ”€β”€[HQπŸš€πŸŒ%F{201}$(ip -4 addr | grep -v '127.0.0.1' | grep -v 'secondary' | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | sed -z 's/\n/|/g;s/|\$/\n/' | rev | cut -c 2- | rev)πŸ”₯%n%F{46}]"$'\n'"└──╼[πŸ‘Ύ]%F{44}%~ $%f "
fi

or a call to a program like:

neofetch

They are not run.

Autosuggestions and Completions can be run only if you put the following code in an external .zshrc file:

if [[ $1 != no-repeat-flag && -z $NO_REPETITION ]]; then
  source ~/.bash_aliases
  source /run/current-system/sw/share/zsh-autosuggestions/zsh-autosuggestions.zsh
  source /run/current-system/sw/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  neofetch
fi

so all these elements don't run if used inside HM ZSH module. Please fix.

Maintainer CC

@rycee @marzipankaiser @uvNikita

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.1.72, Athena OS, 23.11 (Tapir), 23.11.2962.b8dd8be3c790`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
stale[bot] commented 2 months 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.