aboutsummaryrefslogtreecommitdiff
path: root/modules/home/shells/zsh/default.nix
blob: 5da67c9e0db6c9a1a80d85499725a989a9b5ac47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
  config,
  pkgs,
  lib,
  ...
}:

let
  inherit (lib) mkEnableOption mkIf;
  cfg = config.nx.shells.zsh;
in
{
  options.nx.shells.zsh = {
    enable = mkEnableOption "zsh shell";
  };

  config = mkIf cfg.enable {
    home.packages = with pkgs; [
      zoxide
    ];

    programs.zsh = {
      enable = true;
      enableCompletion = true;
      autosuggestion.enable = true;
      syntaxHighlighting.enable = true;
      initContent = ''
        # view man pages with nvim
        export MANPAGER="nvim +Man!"

        # Directory completion with trailing slash
        zstyle ':completion:*' list-dirs-first true
        zstyle ':completion:*' special-dirs true
        zstyle ':completion:*' squeeze-slashes true
        zstyle ':completion:*' add-space false

        # Case-insensitive completion
        zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
        # vim keybindings
        bindkey -v

        # Auto cd - type directory name to cd into it
        setopt AUTO_CD

        # Complete .. to ../ for directory navigation
        setopt AUTO_PARAM_SLASH

        # zoxide smarter cmd command
        eval "$(zoxide init zsh)"
      '';
      shellAliases = {
        ls = "ls --color=auto";
      };

      zplug = {
        enable = true;
        plugins = [
          { name = "mafredri/zsh-async"; }
          {
            name = "sindresorhus/pure";
            tags = [
              "as:theme"
              "use:pure.zsh"
            ];
          }
          { name = "zdharma-continuum/fast-syntax-highlighting"; }
          { name = "zsh-users/zsh-autosuggestions"; }
        ];
      };
    };
  };
}