|
1 | 1 | {
|
2 | 2 | lib,
|
3 |
| - helpers, |
4 |
| - config, |
5 |
| - pkgs, |
6 | 3 | ...
|
7 | 4 | }:
|
8 |
| -with lib; |
9 | 5 | let
|
10 |
| - cfg = config.plugins.notify; |
| 6 | + inherit (lib.nixvim) |
| 7 | + defaultNullOpts |
| 8 | + mkNullOrOption |
| 9 | + ; |
| 10 | + inherit (lib) types; |
11 | 11 | in
|
12 |
| -{ |
13 |
| - options.plugins.notify = lib.nixvim.plugins.neovim.extraOptionsOptions // { |
14 |
| - enable = mkEnableOption "nvim-notify"; |
15 |
| - |
16 |
| - package = lib.mkPackageOption pkgs "nvim-notify" { |
17 |
| - default = [ |
18 |
| - "vimPlugins" |
19 |
| - "nvim-notify" |
20 |
| - ]; |
21 |
| - }; |
22 |
| - |
23 |
| - level = helpers.defaultNullOpts.mkLogLevel "info" '' |
| 12 | +lib.nixvim.plugins.mkNeovimPlugin { |
| 13 | + name = "notify"; |
| 14 | + packPathName = "nvim-notify"; |
| 15 | + package = "nvim-notify"; |
| 16 | + maintainers = [ lib.maintainers.khaneliman ]; |
| 17 | + |
| 18 | + description = '' |
| 19 | + A fancy, configurable, notification manager for Neovim. |
| 20 | + ''; |
| 21 | + |
| 22 | + settingsOptions = { |
| 23 | + level = defaultNullOpts.mkLogLevel "info" '' |
24 | 24 | Minimum log level to display. See `vim.log.levels`.
|
25 | 25 | '';
|
26 |
| - |
27 |
| - timeout = helpers.defaultNullOpts.mkUnsignedInt 5000 "Default timeout for notification."; |
28 |
| - |
29 |
| - maxWidth = helpers.mkNullOrOption (with types; either ints.unsigned rawLua) '' |
| 26 | + timeout = defaultNullOpts.mkUnsignedInt 5000 "Default timeout for notification."; |
| 27 | + max_width = mkNullOrOption (with types; either ints.unsigned rawLua) '' |
30 | 28 | Max number of columns for messages.
|
31 | 29 | '';
|
32 |
| - |
33 |
| - maxHeight = helpers.mkNullOrOption (with types; either ints.unsigned rawLua) '' |
| 30 | + max_height = mkNullOrOption (with types; either ints.unsigned rawLua) '' |
34 | 31 | Max number of lines for a message.
|
35 | 32 | '';
|
36 |
| - |
37 | 33 | stages =
|
38 |
| - helpers.defaultNullOpts.mkNullable |
| 34 | + defaultNullOpts.mkNullable |
39 | 35 | (
|
40 | 36 | with types;
|
41 | 37 | either (enum [
|
|
50 | 46 | Animation stages.
|
51 | 47 | Can be either one of the builtin stages or an array of lua functions.
|
52 | 48 | '';
|
53 |
| - |
54 |
| - backgroundColour = helpers.defaultNullOpts.mkStr "NotifyBackground" '' |
| 49 | + background_colour = defaultNullOpts.mkStr "NotifyBackground" '' |
55 | 50 | For stages that change opacity this is treated as the highlight behind the window.
|
56 | 51 | Set this to either a highlight group, an RGB hex value e.g. "#000000" or a function
|
57 | 52 | returning an RGB code for dynamic values.
|
58 | 53 | '';
|
59 |
| - |
60 |
| - icons = |
61 |
| - mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "Icon for the ${name} level.") |
62 |
| - { |
63 |
| - error = ""; |
64 |
| - warn = ""; |
65 |
| - info = ""; |
66 |
| - debug = ""; |
67 |
| - trace = "✎"; |
68 |
| - }; |
69 |
| - |
70 |
| - onOpen = helpers.defaultNullOpts.mkLuaFn "nil" '' |
| 54 | + icons = lib.mapAttrs (name: default: defaultNullOpts.mkStr default "Icon for the ${name} level.") { |
| 55 | + error = ""; |
| 56 | + warn = ""; |
| 57 | + info = ""; |
| 58 | + debug = ""; |
| 59 | + trace = "✎"; |
| 60 | + }; |
| 61 | + on_open = defaultNullOpts.mkLuaFn "nil" '' |
71 | 62 | Function called when a new window is opened, use for changing win settings/config.
|
72 | 63 | '';
|
73 |
| - |
74 |
| - onClose = helpers.defaultNullOpts.mkLuaFn "nil" '' |
| 64 | + on_close = defaultNullOpts.mkLuaFn "nil" '' |
75 | 65 | Function called when a new window is closed.
|
76 | 66 | '';
|
77 |
| - |
78 |
| - render = helpers.defaultNullOpts.mkEnumFirstDefault [ |
| 67 | + render = defaultNullOpts.mkEnumFirstDefault [ |
79 | 68 | "default"
|
80 | 69 | "minimal"
|
81 | 70 | "simple"
|
82 | 71 | "compact"
|
83 | 72 | "wrapped-compact"
|
84 | 73 | ] "Function to render a notification buffer or a built-in renderer name.";
|
85 |
| - |
86 |
| - minimumWidth = helpers.defaultNullOpts.mkUnsignedInt 50 '' |
| 74 | + minimum_width = defaultNullOpts.mkUnsignedInt 50 '' |
87 | 75 | Minimum width for notification windows.
|
88 | 76 | '';
|
89 |
| - |
90 |
| - fps = helpers.defaultNullOpts.mkPositiveInt 30 '' |
| 77 | + fps = defaultNullOpts.mkPositiveInt 30 '' |
91 | 78 | Frames per second for animation stages, higher value means smoother animations but more CPU
|
92 | 79 | usage.
|
93 | 80 | '';
|
94 |
| - |
95 |
| - topDown = helpers.defaultNullOpts.mkBool true '' |
| 81 | + top_down = defaultNullOpts.mkBool true '' |
96 | 82 | Whether or not to position the notifications at the top or not.
|
97 | 83 | '';
|
98 | 84 | };
|
99 | 85 |
|
100 |
| - config = |
101 |
| - let |
102 |
| - setupOptions = |
103 |
| - with cfg; |
104 |
| - { |
105 |
| - inherit level timeout; |
106 |
| - max_width = maxWidth; |
107 |
| - max_height = maxHeight; |
108 |
| - stages = helpers.ifNonNull' stages (if isString stages then stages else map helpers.mkRaw stages); |
109 |
| - background_colour = backgroundColour; |
110 |
| - icons = mapAttrs' (name: value: { |
111 |
| - name = strings.toUpper name; |
112 |
| - inherit value; |
113 |
| - }) icons; |
114 |
| - on_open = onOpen; |
115 |
| - on_close = onClose; |
116 |
| - inherit render; |
117 |
| - minimum_width = minimumWidth; |
118 |
| - inherit fps; |
119 |
| - top_down = topDown; |
120 |
| - } |
121 |
| - // cfg.extraOptions; |
122 |
| - in |
123 |
| - mkIf cfg.enable { |
124 |
| - extraPlugins = [ cfg.package ]; |
125 |
| - |
126 |
| - extraConfigLua = '' |
127 |
| - vim.notify = require('notify'); |
128 |
| - require('notify').setup(${lib.nixvim.toLuaObject setupOptions}) |
129 |
| - ''; |
| 86 | + settingsExample = { |
| 87 | + settings = { |
| 88 | + level = "info"; |
| 89 | + timeout = 5000; |
| 90 | + max_width = 80; |
| 91 | + max_height = 10; |
| 92 | + stages = "fade_in_slide_out"; |
| 93 | + background_colour = "#000000"; |
| 94 | + icons = { |
| 95 | + error = ""; |
| 96 | + warn = ""; |
| 97 | + info = ""; |
| 98 | + debug = ""; |
| 99 | + trace = "✎"; |
| 100 | + }; |
| 101 | + on_open.__raw = "function() print('Window opened') end"; |
| 102 | + on_close.__raw = "function() print('Window closed') end"; |
| 103 | + render = "default"; |
| 104 | + minimum_width = 50; |
| 105 | + fps = 30; |
| 106 | + top_down = true; |
130 | 107 | };
|
| 108 | + }; |
| 109 | + |
| 110 | + extraConfig = { |
| 111 | + plugins.notify.luaConfig.pre = '' |
| 112 | + vim.notify = require('notify'); |
| 113 | + ''; |
| 114 | + }; |
| 115 | + |
| 116 | + # TODO: Deprecated on 2025-02-01 |
| 117 | + inherit (import ./deprecations.nix) deprecateExtraOptions optionsRenamedToSettings; |
131 | 118 | }
|
0 commit comments