mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/notify: migrate to mkNeovimPlugin
This commit is contained in:
parent
10ea28fff4
commit
0827c5cb6c
3 changed files with 121 additions and 95 deletions
|
@ -1,41 +1,37 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.plugins.notify;
|
inherit (lib.nixvim)
|
||||||
|
defaultNullOpts
|
||||||
|
mkNullOrOption
|
||||||
|
;
|
||||||
|
inherit (lib) types;
|
||||||
in
|
in
|
||||||
{
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
options.plugins.notify = lib.nixvim.plugins.neovim.extraOptionsOptions // {
|
name = "notify";
|
||||||
enable = mkEnableOption "nvim-notify";
|
packPathName = "nvim-notify";
|
||||||
|
package = "nvim-notify";
|
||||||
|
maintainers = [ lib.maintainers.khaneliman ];
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "nvim-notify" {
|
description = ''
|
||||||
default = [
|
A fancy, configurable, notification manager for Neovim.
|
||||||
"vimPlugins"
|
'';
|
||||||
"nvim-notify"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
level = helpers.defaultNullOpts.mkLogLevel "info" ''
|
settingsOptions = {
|
||||||
|
level = defaultNullOpts.mkLogLevel "info" ''
|
||||||
Minimum log level to display. See `vim.log.levels`.
|
Minimum log level to display. See `vim.log.levels`.
|
||||||
'';
|
'';
|
||||||
|
timeout = defaultNullOpts.mkUnsignedInt 5000 "Default timeout for notification.";
|
||||||
timeout = helpers.defaultNullOpts.mkUnsignedInt 5000 "Default timeout for notification.";
|
max_width = mkNullOrOption (with types; either ints.unsigned rawLua) ''
|
||||||
|
|
||||||
maxWidth = helpers.mkNullOrOption (with types; either ints.unsigned rawLua) ''
|
|
||||||
Max number of columns for messages.
|
Max number of columns for messages.
|
||||||
'';
|
'';
|
||||||
|
max_height = mkNullOrOption (with types; either ints.unsigned rawLua) ''
|
||||||
maxHeight = helpers.mkNullOrOption (with types; either ints.unsigned rawLua) ''
|
|
||||||
Max number of lines for a message.
|
Max number of lines for a message.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
stages =
|
stages =
|
||||||
helpers.defaultNullOpts.mkNullable
|
defaultNullOpts.mkNullable
|
||||||
(
|
(
|
||||||
with types;
|
with types;
|
||||||
either (enum [
|
either (enum [
|
||||||
|
@ -50,82 +46,73 @@ in
|
||||||
Animation stages.
|
Animation stages.
|
||||||
Can be either one of the builtin stages or an array of lua functions.
|
Can be either one of the builtin stages or an array of lua functions.
|
||||||
'';
|
'';
|
||||||
|
background_colour = defaultNullOpts.mkStr "NotifyBackground" ''
|
||||||
backgroundColour = helpers.defaultNullOpts.mkStr "NotifyBackground" ''
|
|
||||||
For stages that change opacity this is treated as the highlight behind the window.
|
For stages that change opacity this is treated as the highlight behind the window.
|
||||||
Set this to either a highlight group, an RGB hex value e.g. "#000000" or a function
|
Set this to either a highlight group, an RGB hex value e.g. "#000000" or a function
|
||||||
returning an RGB code for dynamic values.
|
returning an RGB code for dynamic values.
|
||||||
'';
|
'';
|
||||||
|
icons = lib.mapAttrs (name: default: defaultNullOpts.mkStr default "Icon for the ${name} level.") {
|
||||||
icons =
|
error = "";
|
||||||
mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "Icon for the ${name} level.")
|
warn = "";
|
||||||
{
|
info = "";
|
||||||
error = "";
|
debug = "";
|
||||||
warn = "";
|
trace = "✎";
|
||||||
info = "";
|
};
|
||||||
debug = "";
|
on_open = defaultNullOpts.mkLuaFn "nil" ''
|
||||||
trace = "✎";
|
|
||||||
};
|
|
||||||
|
|
||||||
onOpen = helpers.defaultNullOpts.mkLuaFn "nil" ''
|
|
||||||
Function called when a new window is opened, use for changing win settings/config.
|
Function called when a new window is opened, use for changing win settings/config.
|
||||||
'';
|
'';
|
||||||
|
on_close = defaultNullOpts.mkLuaFn "nil" ''
|
||||||
onClose = helpers.defaultNullOpts.mkLuaFn "nil" ''
|
|
||||||
Function called when a new window is closed.
|
Function called when a new window is closed.
|
||||||
'';
|
'';
|
||||||
|
render = defaultNullOpts.mkEnumFirstDefault [
|
||||||
render = helpers.defaultNullOpts.mkEnumFirstDefault [
|
|
||||||
"default"
|
"default"
|
||||||
"minimal"
|
"minimal"
|
||||||
"simple"
|
"simple"
|
||||||
"compact"
|
"compact"
|
||||||
"wrapped-compact"
|
"wrapped-compact"
|
||||||
] "Function to render a notification buffer or a built-in renderer name.";
|
] "Function to render a notification buffer or a built-in renderer name.";
|
||||||
|
minimum_width = defaultNullOpts.mkUnsignedInt 50 ''
|
||||||
minimumWidth = helpers.defaultNullOpts.mkUnsignedInt 50 ''
|
|
||||||
Minimum width for notification windows.
|
Minimum width for notification windows.
|
||||||
'';
|
'';
|
||||||
|
fps = defaultNullOpts.mkPositiveInt 30 ''
|
||||||
fps = helpers.defaultNullOpts.mkPositiveInt 30 ''
|
|
||||||
Frames per second for animation stages, higher value means smoother animations but more CPU
|
Frames per second for animation stages, higher value means smoother animations but more CPU
|
||||||
usage.
|
usage.
|
||||||
'';
|
'';
|
||||||
|
top_down = defaultNullOpts.mkBool true ''
|
||||||
topDown = helpers.defaultNullOpts.mkBool true ''
|
|
||||||
Whether or not to position the notifications at the top or not.
|
Whether or not to position the notifications at the top or not.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
settingsExample = {
|
||||||
let
|
settings = {
|
||||||
setupOptions =
|
level = "info";
|
||||||
with cfg;
|
timeout = 5000;
|
||||||
{
|
max_width = 80;
|
||||||
inherit level timeout;
|
max_height = 10;
|
||||||
max_width = maxWidth;
|
stages = "fade_in_slide_out";
|
||||||
max_height = maxHeight;
|
background_colour = "#000000";
|
||||||
stages = helpers.ifNonNull' stages (if isString stages then stages else map helpers.mkRaw stages);
|
icons = {
|
||||||
background_colour = backgroundColour;
|
error = "";
|
||||||
icons = mapAttrs' (name: value: {
|
warn = "";
|
||||||
name = strings.toUpper name;
|
info = "";
|
||||||
inherit value;
|
debug = "";
|
||||||
}) icons;
|
trace = "✎";
|
||||||
on_open = onOpen;
|
};
|
||||||
on_close = onClose;
|
on_open.__raw = "function() print('Window opened') end";
|
||||||
inherit render;
|
on_close.__raw = "function() print('Window closed') end";
|
||||||
minimum_width = minimumWidth;
|
render = "default";
|
||||||
inherit fps;
|
minimum_width = 50;
|
||||||
top_down = topDown;
|
fps = 30;
|
||||||
}
|
top_down = true;
|
||||||
// cfg.extraOptions;
|
|
||||||
in
|
|
||||||
mkIf cfg.enable {
|
|
||||||
extraPlugins = [ cfg.package ];
|
|
||||||
|
|
||||||
extraConfigLua = ''
|
|
||||||
vim.notify = require('notify');
|
|
||||||
require('notify').setup(${lib.nixvim.toLuaObject setupOptions})
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = {
|
||||||
|
plugins.notify.luaConfig.pre = ''
|
||||||
|
vim.notify = require('notify');
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: Deprecated on 2025-02-01
|
||||||
|
inherit (import ./deprecations.nix) deprecateExtraOptions optionsRenamedToSettings;
|
||||||
}
|
}
|
||||||
|
|
37
plugins/by-name/notify/deprecations.nix
Normal file
37
plugins/by-name/notify/deprecations.nix
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"level"
|
||||||
|
"timeout"
|
||||||
|
"maxWidth"
|
||||||
|
"maxHeight"
|
||||||
|
"stages"
|
||||||
|
"backgroundColour"
|
||||||
|
[
|
||||||
|
"icons"
|
||||||
|
"error"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"icons"
|
||||||
|
"warn"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"icons"
|
||||||
|
"info"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"icons"
|
||||||
|
"debug"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"icons"
|
||||||
|
"trace"
|
||||||
|
]
|
||||||
|
"onOpen"
|
||||||
|
"onClose"
|
||||||
|
"render"
|
||||||
|
"minimumWidth"
|
||||||
|
"fps"
|
||||||
|
"topDown"
|
||||||
|
];
|
||||||
|
}
|
|
@ -7,25 +7,27 @@
|
||||||
plugins.notify = {
|
plugins.notify = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
level = "info";
|
settings = {
|
||||||
timeout = 5000;
|
level = "info";
|
||||||
maxWidth = null;
|
timeout = 5000;
|
||||||
maxHeight = null;
|
max_width = null;
|
||||||
stages = "fade_in_slide_out";
|
max_height = null;
|
||||||
backgroundColour = "NotifyBackground";
|
stages = "fade_in_slide_out";
|
||||||
icons = {
|
background_colour = "NotifyBackground";
|
||||||
error = "";
|
icons = {
|
||||||
warn = "";
|
error = "";
|
||||||
info = "";
|
warn = "";
|
||||||
debug = "";
|
info = "";
|
||||||
trace = "✎";
|
debug = "";
|
||||||
|
trace = "✎";
|
||||||
|
};
|
||||||
|
on_open = null;
|
||||||
|
on_close = null;
|
||||||
|
render = "default";
|
||||||
|
minimum_width = 50;
|
||||||
|
fps = 30;
|
||||||
|
top_down = true;
|
||||||
};
|
};
|
||||||
onOpen = null;
|
|
||||||
onClose = null;
|
|
||||||
render = "default";
|
|
||||||
minimumWidth = 50;
|
|
||||||
fps = 30;
|
|
||||||
topDown = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue