aboutsummaryrefslogtreecommitdiffstats
path: root/modules/terminal/fzf/default.nix
blob: 080e6a28731d8ddb1d8874ef458f7a52836d2981 (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
# Fuzzy finder, CLI fuzzy search tool
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.terminal.fzf;
  base16Colors = import ../../colors/base16 { inherit config lib pkgs; };

  shellIntegration = ''
    ${if config.terminal.zsh.enable then "eval \"$(fzf --zsh)\"" else "eval \"$(fzf --bash)\""}
  '';
in
{
  imports = [ ./assertions.nix ];

  options.terminal.fzf = {
    enable = lib.mkEnableOption "Enables fzf.";
    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = config.programs.fzf.package;
      description = "The fzf package to use.";
    };
  };

  config = lib.mkIf cfg.enable {
    programs.fzf = {
      enable = true;
      defaultOptions = [
        "--height 100%"
        "--layout=reverse"
        "--pointer='󰠁 '"
        "--header=' '"
        "--prompt='󰎕 '"
        "--marker='✓ '"
        "--border=none"
        "--cycle"
        "--no-info"
        "--margin='1,2'"
      ];

      colors = with base16Colors.colorsWithHashPrefix; {
        fg = base05;
        bg = "-1";
        hl = base0D;

        "fg+" = base07;
        "bg+" = "-1";
        "hl+" = base0D;

        gutter = "-1";

        info = base0B;
        border = base03;
        prompt = base0A;
        pointer = base0F;
        marker = base0C;
        spinner = base0C;
      };
    };

    programs.zsh.initContent = lib.mkIf config.terminal.zsh.enable (lib.mkAfter shellIntegration);
  };
}