summaryrefslogtreecommitdiffstats
path: root/modules/plugins/ui/ui2/ui2.nix
blob: 67a4fea9e2d6b7bd1cfe61339ffb8cb248b2dfdb (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
73
74
75
76
77
{lib, ...}: let
  inherit (lib.options) mkEnableOption mkOption;
  inherit
    (lib.types)
    nullOr
    oneOf
    enum
    attrsOf
    number
    int
    ;
  inherit (lib.nvim.types) mkPluginSetupOption;

  # Top-level targets only accepts `cmd` and `msg`, which is shorter, so we define that one
  # inline below. This is the accepted targets for ui2 messages when defining it as a table
  # or an attrset in Nix.
  msgTargetEnum = enum [
    "cmd"
    "msg"
    "pager"
  ];

  heightOption = target: default:
    mkOption {
      description = "Maximum height for the ${target} window";
      type = number;
      inherit default;
    };
in {
  options.vim.ui.ui2 = {
    enable = mkEnableOption "the Neovim 0.12+ experimental built-in UI overhaul";

    setupOpts = mkPluginSetupOption "ui2" {
      msg = {
        targets = mkOption {
          description = ''
            Default message target, either commandline or a separate window.
            Can alternatively specify different targets for different kinds of messages as an attrset.
            See [`:h ui-messages`](https://neovim.io/doc/user/api-ui-events/#ui-messages)
            for the different message types you can use in this configuration.
            Separating the message types also allows sending to a 'pager' output.
          '';
          type = nullOr (oneOf [
            (enum [
              "cmd"
              "msg"
            ])
            (attrsOf msgTargetEnum)
          ]);
          default = "cmd";
          example = {
            bufwrite = "cmd";
            quickfix = "msg";
          };
        };
        cmd = {
          height = heightOption "cmdline" 0.5;
        };
        dialog = {
          height = heightOption "dialog" 0.5;
        };
        msg = {
          height = heightOption "msg" 0.5;
          timeout = mkOption {
            description = "Time a message is visible in the message window";
            type = int;
            default = 4000;
            example = 1500;
          };
        };
        pager = {
          height = heightOption "pager" 1;
        };
      };
    };
  };
}