modules/ui: switch to explicit lib calls

This commit is contained in:
raf 2024-03-16 16:25:30 +03:00
parent 81b9a8a95c
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

@ -3,7 +3,8 @@
lib,
...
}: let
inherit (lib) mkOption mkEnableOption types;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum;
cfg = config.vim.ui.borders;
@ -13,10 +14,10 @@ in {
enable = mkEnableOption "visible borders for most windows";
globalStyle = mkOption {
type = types.enum defaultStyles;
type = enum defaultStyles;
default = "rounded";
description = ''
global border style to use
The global border style to use
'';
};
@ -26,14 +27,14 @@ in {
enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption {
type = types.enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]);
type = enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle;
description = "border style to use for the ${name} plugin";
description = "The border style to use for the ${name} plugin";
};
};
in {
# despite not having it listed in example configuration, which-key does support the rounded type
# additionall, it supports a "shadow" type that is similar to none but is of higher contrast
# additionally, it supports a "shadow" type that is similar to none but is of higher contrast
which-key = mkPluginStyleOption "which-key";
lspsaga = mkPluginStyleOption "lspsaga";
nvim-cmp = mkPluginStyleOption "nvim-cmp";

View file

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

View file

@ -1,14 +1,15 @@
{
lib,
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) nullOr listOf enum bool str int;
in {
options.vim.ui.breadcrumbs = {
enable = lib.mkEnableOption "breadcrumbs";
enable = mkEnableOption "breadcrumbs";
source = mkOption {
type = with types; nullOr (enum ["nvim-navic"]); # TODO: lspsaga and dropbar
type = nullOr (enum ["nvim-navic"]); # TODO: lspsaga and dropbar
default = "nvim-navic";
description = ''
The source to be used for breadcrumbs component. Null means no breadcrumbs.
@ -18,7 +19,7 @@ in {
# maybe this should be an option to *disable* alwaysRender optionally but oh well
# too late
alwaysRender = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Whether to always display the breadcrumbs component on winbar (always renders winbar)";
};
@ -28,152 +29,152 @@ in {
# this option is interpreted as null if mkEnableOption is used, and therefore cannot be converted to a string in config.nix
useDefaultMappings = mkOption {
type = types.bool;
type = bool;
default = true;
description = "use default Navbuddy keybindings (disables user-specified keybinds)";
};
mappings = {
close = mkOption {
type = types.str;
type = str;
default = "<esc>";
description = "keybinding to close Navbuddy UI";
};
nextSibling = mkOption {
type = types.str;
type = str;
default = "j";
description = "keybinding to navigate to the next sibling node";
};
previousSibling = mkOption {
type = types.str;
type = str;
default = "k";
description = "keybinding to navigate to the previous sibling node";
};
parent = mkOption {
type = types.str;
type = str;
default = "h";
description = "keybinding to navigate to the parent node";
};
children = mkOption {
type = types.str;
type = str;
default = "h";
description = "keybinding to navigate to the child node";
};
root = mkOption {
type = types.str;
type = str;
default = "0";
description = "keybinding to navigate to the root node";
};
visualName = mkOption {
type = types.str;
type = str;
default = "v";
description = "visual selection of name";
};
visualScope = mkOption {
type = types.str;
type = str;
default = "V";
description = "visual selection of scope";
};
yankName = mkOption {
type = types.str;
type = str;
default = "y";
description = "yank the name to system clipboard";
};
yankScope = mkOption {
type = types.str;
type = str;
default = "Y";
description = "yank the scope to system clipboard";
};
insertName = mkOption {
type = types.str;
type = str;
default = "i";
description = "insert at start of name";
};
insertScope = mkOption {
type = types.str;
type = str;
default = "I";
description = "insert at start of scope";
};
appendName = mkOption {
type = types.str;
type = str;
default = "a";
description = "insert at end of name";
};
appendScope = mkOption {
type = types.str;
type = str;
default = "A";
description = "insert at end of scope";
};
rename = mkOption {
type = types.str;
type = str;
default = "r";
description = "rename the node";
};
delete = mkOption {
type = types.str;
type = str;
default = "d";
description = "delete the node";
};
foldCreate = mkOption {
type = types.str;
type = str;
default = "f";
description = "create a new fold";
};
foldDelete = mkOption {
type = types.str;
type = str;
default = "F";
description = "delete the current fold";
};
comment = mkOption {
type = types.str;
type = str;
default = "c";
description = "comment the node";
};
select = mkOption {
type = types.str;
type = str;
default = "<enter>";
description = "goto selected symbol";
};
moveDown = mkOption {
type = types.str;
type = str;
default = "J";
description = "move focused node down";
};
moveUp = mkOption {
type = types.str;
type = str;
default = "K";
description = "move focused node up";
};
telescope = mkOption {
type = types.str;
type = str;
default = "t";
description = "fuzzy finder at current level";
};
help = mkOption {
type = types.str;
type = str;
default = "g?";
description = "open mapping help window";
};
@ -185,13 +186,13 @@ in {
border = mkOption {
# TODO: let this type accept a custom string
type = types.enum ["single" "rounded" "double" "solid" "none"];
type = enum ["single" "rounded" "double" "solid" "none"];
default = config.vim.ui.borders.globalStyle;
description = "border style to use";
};
scrolloff = mkOption {
type = with types; nullOr int;
type = nullOr int;
default = null;
description = "Scrolloff value within navbuddy window";
};
@ -209,7 +210,7 @@ in {
border = mkOption {
# TODO: let this type accept a custom string
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the left section of Navbuddy UI";
};
@ -227,7 +228,7 @@ in {
border = mkOption {
# TODO: let this type accept a custom string
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the middle section of Navbuddy UI";
};
@ -238,13 +239,13 @@ in {
right = {
border = mkOption {
# TODO: let this type accept a custom string
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the right section of Navbuddy UI";
};
preview = mkOption {
type = types.enum ["leaf" "always" "never"];
type = enum ["leaf" "always" "never"];
default = "leaf";
description = "display mode of the preview on the right section";
};
@ -256,19 +257,19 @@ in {
enable = mkEnableOption "node markers";
icons = {
leaf = mkOption {
type = types.str;
type = str;
default = " ";
description = "";
};
leafSelected = mkOption {
type = types.str;
type = str;
default = " ";
description = "";
};
branch = mkOption {
type = types.str;
type = str;
default = " ";
description = "";
};
@ -277,13 +278,13 @@ in {
lsp = {
autoAttach = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Whether to attach to LSP server manually";
};
preference = mkOption {
type = with types; nullOr (listOf str);
type = nullOr (listOf str);
default = null;
description = "list of lsp server names in order of preference";
};
@ -291,25 +292,25 @@ in {
sourceBuffer = {
followNode = mkOption {
type = types.bool;
type = bool;
default = true;
description = "keep the current node in focus on the source buffer";
};
highlight = mkOption {
type = types.bool;
type = bool;
default = true;
description = "highlight the currently focused node";
};
reorient = mkOption {
type = types.enum ["smart" "top" "mid" "none"];
type = enum ["smart" "top" "mid" "none"];
default = "smart";
description = "reorient buffer after changing nodes";
};
scrolloff = mkOption {
type = with types; nullOr int;
type = nullOr int;
default = null;
description = "scrolloff value when navbuddy is open";
};
@ -319,159 +320,159 @@ in {
# alas, I am not a nix wizard
icons = {
file = mkOption {
type = types.str;
type = str;
default = "󰈙 ";
description = "";
description = "File icon";
};
module = mkOption {
type = types.str;
type = str;
default = " ";
description = "";
description = "Module icon";
};
namespace = mkOption {
type = types.str;
type = str;
default = "󰌗 ";
description = "";
description = "Namespace icon";
};
package = mkOption {
type = types.str;
default = " ";
description = "";
type = str;
default = " ";
description = "Package icon";
};
class = mkOption {
type = types.str;
type = str;
default = "󰌗 ";
description = "";
description = "Class icon";
};
property = mkOption {
type = types.str;
default = " ";
description = "";
type = str;
default = " ";
description = "Property icon";
};
field = mkOption {
type = types.str;
type = str;
default = " ";
description = "";
description = "Field icon";
};
constructor = mkOption {
type = types.str;
type = str;
default = " ";
description = "";
description = "Constructor icon";
};
enum = mkOption {
type = types.str;
type = str;
default = "󰕘";
description = "";
description = "Enum icon";
};
interface = mkOption {
type = types.str;
type = str;
default = "󰕘";
description = "";
description = "Interface icon";
};
function = mkOption {
type = types.str;
type = str;
default = "󰊕 ";
description = "";
description = "Function icon";
};
variable = mkOption {
type = types.str;
default = "󰆧 ";
description = "";
type = str;
default = "󰫧 ";
description = "Variable icon";
};
constant = mkOption {
type = types.str;
type = str;
default = "󰏿 ";
description = "";
description = "Constant icon";
};
string = mkOption {
type = types.str;
default = " ";
description = "";
type = str;
default = " ";
description = "String icon";
};
number = mkOption {
type = types.str;
type = str;
default = "󰎠 ";
description = "";
description = "Number icon";
};
boolean = mkOption {
type = types.str;
default = " ";
description = "";
type = str;
default = " ";
description = "Boolean icon";
};
array = mkOption {
type = types.str;
type = str;
default = "󰅪 ";
description = "";
description = "Array icon";
};
object = mkOption {
type = types.str;
type = str;
default = "󰅩 ";
description = "";
description = "Object icon";
};
method = mkOption {
type = types.str;
type = str;
default = "󰆧 ";
description = "";
description = "Method icon";
};
key = mkOption {
type = types.str;
type = str;
default = "󰌋 ";
description = "";
description = "Key icon";
};
null = mkOption {
type = types.str;
type = str;
default = "󰟢 ";
description = "";
description = "Null icon";
};
enumMember = mkOption {
type = types.str;
type = str;
default = "󰕘 ";
description = "";
description = "Enum member icon";
};
struct = mkOption {
type = types.str;
type = str;
default = "󰌗 ";
description = "";
description = "Struct icon";
};
event = mkOption {
type = types.str;
type = str;
default = " ";
description = "";
description = "Event icon";
};
operator = mkOption {
type = types.str;
type = str;
default = "󰆕 ";
description = "";
description = "Operator icon";
};
typeParameter = mkOption {
type = types.str;
type = str;
default = "󰊄 ";
description = "";
description = "Type parameter icon";
};
};
};

View file

@ -3,11 +3,15 @@
lib,
...
}: let
inherit (lib) optionalString boolToString mkIf optionals;
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.lists) optionals;
inherit (lib.nvim.lua) nullString;
inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.ui.breadcrumbs;
nb = cfg.navbuddy;
nbcfg = cfg.navbuddy;
in {
config = mkIf cfg.enable {
vim.startPlugins =
@ -26,7 +30,7 @@ in {
"nvim-navic"
];
vim.luaConfigRC.breadcrumbs = lib.nvim.dag.entryAfter ["lspconfig"] ''
vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] ''
${optionalString (cfg.source == "nvim-navic") ''
local navic = require("nvim-navic")
@ -40,46 +44,46 @@ in {
local actions = require("nvim-navbuddy.actions")
navbuddy.setup {
window = {
border = "${nb.window.border}", -- "rounded", "double", "solid", "none"
border = "${nbcfg.window.border}", -- "rounded", "double", "solid", "none"
size = "60%",
position = "50%",
scrolloff = ${(nullString nb.window.scrolloff)},
scrolloff = ${(nullString nbcfg.window.scrolloff)},
sections = {
left = {
size = "20%",
border = ${(nullString nb.window.sections.left.border)},
border = ${(nullString nbcfg.window.sections.left.border)},
},
mid = {
size = "40%",
border = ${(nullString nb.window.sections.mid.border)},
border = ${(nullString nbcfg.window.sections.mid.border)},
},
right = {
border = ${(nullString nb.window.sections.right.border)},
border = ${(nullString nbcfg.window.sections.right.border)},
preview = "leaf",
}
},
},
node_markers = {
enabled = ${boolToString nb.nodeMarkers.enable},
enabled = ${boolToString nbcfg.nodeMarkers.enable},
icons = {
leaf = "${nb.nodeMarkers.icons.leaf}",
leaf_selected = "${nb.nodeMarkers.icons.leafSelected}",
branch = "${nb.nodeMarkers.icons.branch}",
leaf = "${nbcfg.nodeMarkers.icons.leaf}",
leaf_selected = "${nbcfg.nodeMarkers.icons.leafSelected}",
branch = "${nbcfg.nodeMarkers.icons.branch}",
},
},
lsp = {
auto_attach = ${boolToString nb.lsp.autoAttach},
auto_attach = ${boolToString nbcfg.lsp.autoAttach},
-- preference = nil, -- TODO: convert list to lua table if not null
},
source_buffer = {
follow_node = ${boolToString nb.sourceBuffer.followNode},
highlight = ${boolToString nb.sourceBuffer.highlight},
reorient = "${nb.sourceBuffer.reorient}",
scrolloff = ${nullString nb.sourceBuffer.scrolloff}
follow_node = ${boolToString nbcfg.sourceBuffer.followNode},
highlight = ${boolToString nbcfg.sourceBuffer.highlight},
reorient = "${nbcfg.sourceBuffer.reorient}",
scrolloff = ${nullString nbcfg.sourceBuffer.scrolloff}
},
icons = {

View file

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

View file

@ -1,15 +1,12 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrsOf attrs bool enum;
in {
options.vim.ui.colorizer = {
enable = mkEnableOption "nvim-colorizer.lua for color highlighting";
enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";
filetypes = mkOption {
type = with types; attrsOf attrs;
type = attrsOf attrs;
default = {
css = {};
scss = {};
@ -18,77 +15,54 @@ in {
};
options = {
alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
rgb = mkOption {
type = types.bool;
type = bool;
default = true;
description = "#RGB hex codes";
};
rrggbb = mkOption {
type = types.bool;
type = bool;
default = true;
description = "#RRGGBB hex codes";
};
names = mkOption {
type = types.bool;
type = bool;
default = true;
description = ''"Name" codes such as "Blue"'';
};
rgb_fn = mkOption {
type = types.bool;
type = bool;
default = false;
description = "CSS rgb() and rgba() functions";
};
rrggbbaa = mkOption {
type = types.bool;
type = bool;
default = false;
description = "#RRGGBBAA hex codes";
};
hsl_fn = mkOption {
type = types.bool;
type = bool;
default = false;
description = "CSS hsl() and hsla() functions";
};
css = mkOption {
type = types.bool;
default = false;
description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
};
css_fn = mkOption {
type = types.bool;
default = false;
description = "Enable all CSS *functions*: rgb_fn, hsl_fn";
};
mode = mkOption {
type = types.enum ["foreground" "background"];
type = enum ["foreground" "background"];
default = "background";
description = "Set the display mode";
};
tailwind = mkOption {
type = types.bool;
default = false;
description = "Enable tailwind colors";
};
sass = mkOption {
type = types.bool;
default = false;
description = "Enable sass colors";
};
alwaysUpdate = mkOption {
type = types.bool;
default = false;
description = "Update color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
};
tailwind = mkEnableOption "tailwind colors";
sass = mkEnableOption "sass colors";
css = mkEnableOption "all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
css_fn = mkEnableOption "all CSS *functions*: rgb_fn, hsl_fn";
};
};
}

View file

@ -1,10 +1,12 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf nvim boolToString;
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.lua) attrsetToLuaTable;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.colorizer;
in {
@ -13,14 +15,14 @@ in {
"nvim-colorizer-lua"
];
vim.luaConfigRC.colorizer = nvim.dag.entryAnywhere ''
vim.luaConfigRC.colorizer = entryAnywhere ''
require('colorizer').setup({
filetypes = ${nvim.lua.attrsetToLuaTable cfg.filetypes},
filetypes = ${attrsetToLuaTable cfg.filetypes},
user_default_options = {
RGB = ${boolToString cfg.options.rgb};
RRGGBB = ${boolToString cfg.options.rrggbb};
names = ${boolToString cfg.options.names};
RRGGBBAA = ${boolToString cfg.options.rrggbbaa};
names = ${boolToString cfg.options.names};
rgb_fn = ${boolToString cfg.options.rgb_fn};
hsl_fn = ${boolToString cfg.options.hsl_fn};
css = ${boolToString cfg.options.css};

View file

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

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./noice
./modes

View file

@ -3,14 +3,15 @@
lib,
...
}: let
inherit (lib) mkIf nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.illuminate;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["vim-illuminate"];
vim.luaConfigRC.vim-illuminate = nvim.dag.entryAnywhere ''
vim.luaConfigRC.vim-illuminate = entryAnywhere ''
require('illuminate').configure({
filetypes_denylist = {
'dirvish',

View file

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

View file

@ -1,11 +1,7 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption;
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.ui.illuminate = {
enable = mkEnableOption "vim-illuminate: automatically highlight other uses of the word under the cursor";
enable = mkEnableOption "automatically highlight other uses of the word under the cursor [vim-illuminate]";
};
}

View file

@ -3,7 +3,9 @@
lib,
...
}: let
inherit (lib) mkIf nvim boolToString;
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.modes-nvim;
in {
@ -12,7 +14,7 @@ in {
"modes-nvim"
];
vim.luaConfigRC.modes-nvim = nvim.dag.entryAnywhere ''
vim.luaConfigRC.modes-nvim = entryAnywhere ''
require('modes').setup({
set_cursorline = ${boolToString cfg.setCursorline},
line_opacity = {

View file

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

View file

@ -1,33 +1,31 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str;
in {
options.vim.ui.modes-nvim = {
enable = mkEnableOption "modes.nvim's prismatic line decorations";
setCursorline = mkOption {
type = types.bool;
description = "Set a colored cursorline on current line";
default = false; # looks ugly, disabled by default
};
enable = mkEnableOption "prismatic line decorations [modes.nvim]";
setCursorline = mkEnableOption "colored cursorline on current line";
colors = {
copy = mkOption {
type = types.str;
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
default = "#f5c359";
};
delete = mkOption {
type = types.str;
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
default = "#c75c6a";
};
insert = mkOption {
type = types.str;
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
default = "#78ccc5";
};
visual = mkOption {
type = types.str;
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
default = "#9745be";
};

View file

@ -3,7 +3,9 @@
lib,
...
}: let
inherit (lib) mkIf nvim boolToString;
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.noice;
in {
@ -13,7 +15,7 @@ in {
"nui-nvim"
];
vim.luaConfigRC.noice-nvim = nvim.dag.entryAnywhere ''
vim.luaConfigRC.noice-nvim = entryAnywhere ''
require("noice").setup({
lsp = {
override = {

View file

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

View file

@ -1,11 +1,7 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib) mkEnableOption;
in {
options.vim.ui.noice = {
enable = mkEnableOption "noice-nvim UI modification library";
enable = mkEnableOption "UI modification library [noice.nvim]";
};
}

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 = "";

View file

@ -1,26 +1,27 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf nvim concatStringsSep;
inherit (lib.modules) mkIf;
inherit (lib.strings) concatStringsSep;
inherit (lib.nvim.lua) attrsetToLuaTable;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.smartcolumn;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"smartcolumn"
];
vim = {
startPlugins = ["smartcolumn"];
vim.luaConfigRC.smartcolumn = nvim.dag.entryAnywhere ''
require("smartcolumn").setup({
colorcolumn = "${toString cfg.showColumnAt}",
-- { "help", "text", "markdown", "NvimTree", "alpha"},
disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} },
custom_colorcolumn = ${nvim.lua.attrsetToLuaTable cfg.columnAt.languages},
scope = "file",
})
'';
luaConfigRC.smartcolumn = entryAnywhere ''
require("smartcolumn").setup({
colorcolumn = "${toString cfg.showColumnAt}",
-- { "help", "text", "markdown", "NvimTree", "alpha"},
disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} },
custom_colorcolumn = ${attrsetToLuaTable cfg.columnAt.languages},
scope = "file",
})
'';
};
};
}

View file

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

View file

@ -1,17 +1,18 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types literalExpression;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf either nullOr listOf int str submodule;
in {
options.vim.ui.smartcolumn = {
enable = mkEnableOption "line length indicator";
showColumnAt = mkOption {
type = types.nullOr types.int;
type = nullOr int;
default = 120;
description = "The position at which the column will be displayed. Set to null to disable";
};
disabledFiletypes = mkOption {
type = types.listOf types.str;
type = listOf str;
default = ["help" "text" "markdown" "NvimTree" "alpha"];
description = "The filetypes smartcolumn will be disabled for.";
};
@ -19,8 +20,8 @@ in {
columnAt = {
languages = mkOption {
description = "The position at which smart column should be displayed for each individual buffer type";
type = types.submodule {
freeformType = with types; attrsOf (either int (listOf int));
type = submodule {
freeformType = attrsOf (either int (listOf int));
};
example = literalExpression ''