summaryrefslogtreecommitdiff
path: root/modules/programs/zsh/default.nix
diff options
context:
space:
mode:
authorMike Vink <59492084+ivi-vink@users.noreply.github.com>2025-01-16 22:22:34 +0100
committerGitHub <noreply@github.com>2025-01-16 22:22:34 +0100
commit8e7bd91f353caacc0bc4105f573eb3e17f09e03a (patch)
treec5059edcbebd9644290cad7c653c49a36d593021 /modules/programs/zsh/default.nix
parent6bd39d420578aacf7c0bab7de3e7027b952115ae (diff)
parentbd921223ba7cdac346477d7ea5204d6f4736fcc6 (diff)
Merge branch 'LnL7:master' into masterHEADmaster
Diffstat (limited to 'modules/programs/zsh/default.nix')
-rw-r--r--modules/programs/zsh/default.nix73
1 files changed, 42 insertions, 31 deletions
diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix
index cce645c..65689ba 100644
--- a/modules/programs/zsh/default.nix
+++ b/modules/programs/zsh/default.nix
@@ -18,14 +18,14 @@ in
options = {
programs.zsh.enable = mkOption {
type = types.bool;
- default = false;
- description = lib.mdDoc "Whether to configure zsh as an interactive shell.";
+ default = true;
+ description = "Whether to configure zsh as an interactive shell.";
};
programs.zsh.variables = mkOption {
type = types.attrsOf (types.either types.str (types.listOf types.str));
default = {};
- description = lib.mdDoc ''
+ description = ''
A set of environment variables used in the global environment.
These variables will be set on shell initialisation.
The value of each variable can be either a string or a list of
@@ -38,44 +38,44 @@ in
programs.zsh.shellInit = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Shell script code called during zsh shell initialisation.";
+ description = "Shell script code called during zsh shell initialisation.";
};
programs.zsh.loginShellInit = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Shell script code called during zsh login shell initialisation.";
+ description = "Shell script code called during zsh login shell initialisation.";
};
programs.zsh.interactiveShellInit = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Shell script code called during interactive zsh shell initialisation.";
+ description = "Shell script code called during interactive zsh shell initialisation.";
};
programs.zsh.promptInit = mkOption {
type = types.lines;
- default = "autoload -U promptinit && promptinit && prompt walters && setopt prompt_sp";
- description = lib.mdDoc "Shell script code used to initialise the zsh prompt.";
+ default = "autoload -U promptinit && promptinit && prompt suse && setopt prompt_sp";
+ description = "Shell script code used to initialise the zsh prompt.";
};
programs.zsh.enableCompletion = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc "Enable zsh completion for all interactive zsh shells.";
+ description = "Enable zsh completion for all interactive zsh shells.";
};
programs.zsh.enableBashCompletion = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc "Enable bash completion for all interactive zsh shells.";
+ description = "Enable bash completion for all interactive zsh shells.";
};
programs.zsh.enableGlobalCompInit = mkOption {
type = types.bool;
default = cfg.enableCompletion;
defaultText = literalExpression "config.${opt.enableCompletion}";
- description = lib.mdDoc ''
+ description = ''
Enable execution of compinit call for all interactive zsh shells.
This option can be disabled if the user wants to extend its
@@ -87,35 +87,44 @@ in
programs.zsh.enableFzfCompletion = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable fzf completion.";
+ description = "Enable fzf completion.";
};
programs.zsh.enableFzfGit = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable fzf keybindings for C-g git browsing.";
+ description = "Enable fzf keybindings for C-g git browsing.";
};
programs.zsh.enableFzfHistory = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable fzf keybinding for Ctrl-r history search.";
+ description = "Enable fzf keybinding for Ctrl-r history search.";
};
programs.zsh.enableSyntaxHighlighting = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable zsh-syntax-highlighting.";
+ description = "Enable zsh-syntax-highlighting.";
};
+
+ programs.zsh.enableFastSyntaxHighlighting = mkEnableOption "zsh-fast-syntax-highlighting";
};
config = mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = !(cfg.enableSyntaxHighlighting && cfg.enableFastSyntaxHighlighting);
+ message = "zsh-syntax-highlighting and zsh-fast-syntax-highlighting are mutually exclusive, please disable one of them.";
+ }
+ ];
environment.systemPackages =
[ # Include zsh package
pkgs.zsh
] ++ optional cfg.enableCompletion pkgs.nix-zsh-completions
- ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting;
+ ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting
+ ++ optional cfg.enableFastSyntaxHighlighting pkgs.zsh-fast-syntax-highlighting;
environment.pathsToLink = [ "/share/zsh" ];
@@ -124,18 +133,21 @@ in
# This file is read for all shells.
# Only execute this file once per shell.
- # But don't clobber the environment of interactive non-login children!
- if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi
- export __ETC_ZSHENV_SOURCED=1
+ if [ -n "''${__ETC_ZSHENV_SOURCED-}" ]; then return; fi
+ __ETC_ZSHENV_SOURCED=1
- # Don't execute this file when running in a pure nix-shell.
- if test -n "$IN_NIX_SHELL"; then return; fi
+ if [[ -o rcs ]]; then
+ if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then
+ . ${config.system.build.setEnvironment}
+ fi
- if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then
- . ${config.system.build.setEnvironment}
- fi
+ # Tell zsh how to find installed completions
+ for p in ''${(z)NIX_PROFILES}; do
+ fpath=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions $fpath)
+ done
- ${cfg.shellInit}
+ ${cfg.shellInit}
+ fi
# Read system-wide modifications.
if test -f /etc/zshenv.local; then
@@ -148,7 +160,7 @@ in
# This file is read for login shells.
# Only execute this file once per shell.
- if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi
+ if [ -n "''${__ETC_ZPROFILE_SOURCED-}" ]; then return; fi
__ETC_ZPROFILE_SOURCED=1
${concatStringsSep "\n" zshVariables}
@@ -182,11 +194,6 @@ in
${config.environment.interactiveShellInit}
${cfg.interactiveShellInit}
- # Tell zsh how to find installed completions
- for p in ''${(z)NIX_PROFILES}; do
- fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions)
- done
-
${cfg.promptInit}
${optionalString cfg.enableGlobalCompInit "autoload -U compinit && compinit"}
@@ -196,6 +203,10 @@ in
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
}
+ ${optionalString cfg.enableFastSyntaxHighlighting
+ "source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"
+ }
+
${optionalString cfg.enableFzfCompletion "source ${fzfCompletion}"}
${optionalString cfg.enableFzfGit "source ${fzfGit}"}
${optionalString cfg.enableFzfHistory "source ${fzfHistory}"}