modules/ui: switch to explicit lib calls

This commit is contained in:
raf 2024-03-16 16:25:30 +03:00
commit a7531186a8
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
25 changed files with 251 additions and 272 deletions

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./nvim-notify
];

View file

@ -3,37 +3,40 @@
lib,
...
}: let
inherit (lib) mkIf nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.notify.nvim-notify;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["nvim-notify"];
vim = {
startPlugins = ["nvim-notify"];
vim.luaConfigRC.nvim-notify = nvim.dag.entryAnywhere ''
require('notify').setup {
stages = "${cfg.stages}",
timeout = ${toString cfg.timeout},
background_colour = "${cfg.background_colour}",
position = "${cfg.position}",
icons = {
ERROR = "${cfg.icons.ERROR}",
WARN = "${cfg.icons.WARN}",
INFO = "${cfg.icons.INFO}",
DEBUG = "${cfg.icons.DEBUG}",
TRACE = "${cfg.icons.TRACE}",
},
}
luaConfigRC.nvim-notify = entryAnywhere ''
require('notify').setup {
stages = "${cfg.stages}",
timeout = ${toString cfg.timeout},
background_colour = "${cfg.background_colour}",
position = "${cfg.position}",
icons = {
ERROR = "${cfg.icons.ERROR}",
WARN = "${cfg.icons.WARN}",
INFO = "${cfg.icons.INFO}",
DEBUG = "${cfg.icons.DEBUG}",
TRACE = "${cfg.icons.TRACE}",
},
}
-- required to fix offset_encoding errors
local notify = vim.notify
vim.notify = function(msg, ...)
if msg:match("warning: multiple different client offset_encodings") then
return
-- required to fix offset_encoding errors
local notify = vim.notify
vim.notify = function(msg, ...)
if msg:match("warning: multiple different client offset_encodings") then
return
end
notify(msg, ...)
end
notify(msg, ...)
end
'';
'';
};
};
}

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./config.nix
./nvim-notify.nix

View file

@ -1,38 +1,35 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum int str attrsOf;
in {
options.vim.notify.nvim-notify = {
enable = mkEnableOption "nvim-notify notifications";
stages = mkOption {
type = types.enum ["fade_in_slide_out" "fade_in" "slide_out" "none"];
type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"];
default = "fade_in_slide_out";
description = "The stages of the notification";
};
timeout = mkOption {
type = types.int;
type = int;
default = 1000;
description = "The timeout of the notification";
};
background_colour = mkOption {
type = types.str;
type = str;
default = "#000000";
description = "The background colour of the notification";
};
position = mkOption {
type = types.enum ["top_left" "top_right" "bottom_left" "bottom_right"];
type = enum ["top_left" "top_right" "bottom_left" "bottom_right"];
default = "top_right";
description = "The position of the notification";
};
icons = mkOption {
type = types.attrsOf types.str;
type = attrsOf str;
description = "The icons of the notification";
default = {
ERROR = "";