modules/ui: switch to explicit lib calls

This commit is contained in:
NotAShelf 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, lib,
... ...
}: let }: let
inherit (lib) mkOption mkEnableOption types; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum;
cfg = config.vim.ui.borders; cfg = config.vim.ui.borders;
@ -13,10 +14,10 @@ in {
enable = mkEnableOption "visible borders for most windows"; enable = mkEnableOption "visible borders for most windows";
globalStyle = mkOption { globalStyle = mkOption {
type = types.enum defaultStyles; type = enum defaultStyles;
default = "rounded"; default = "rounded";
description = '' 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;}; enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption { style = mkOption {
type = types.enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]); type = enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle; default = cfg.globalStyle;
description = "border style to use for the ${name} plugin"; description = "The border style to use for the ${name} plugin";
}; };
}; };
in { in {
# despite not having it listed in example configuration, which-key does support the rounded type # 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"; which-key = mkPluginStyleOption "which-key";
lspsaga = mkPluginStyleOption "lspsaga"; lspsaga = mkPluginStyleOption "lspsaga";
nvim-cmp = mkPluginStyleOption "nvim-cmp"; nvim-cmp = mkPluginStyleOption "nvim-cmp";

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,7 @@
{ {lib, ...}: let
config, inherit (lib.options) mkEnableOption;
lib,
...
}: let
inherit (lib) mkEnableOption;
in { in {
options.vim.ui.illuminate = { 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, lib,
... ...
}: let }: 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; cfg = config.vim.ui.modes-nvim;
in { in {
@ -12,7 +14,7 @@ in {
"modes-nvim" "modes-nvim"
]; ];
vim.luaConfigRC.modes-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.modes-nvim = entryAnywhere ''
require('modes').setup({ require('modes').setup({
set_cursorline = ${boolToString cfg.setCursorline}, set_cursorline = ${boolToString cfg.setCursorline},
line_opacity = { line_opacity = {

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,7 @@
{ {lib, ...}: let
config,
lib,
...
}: let
inherit (lib) mkEnableOption; inherit (lib) mkEnableOption;
in { in {
options.vim.ui.noice = { 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 = [ imports = [
./nvim-notify ./nvim-notify
]; ];

View file

@ -3,14 +3,16 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.notify.nvim-notify; cfg = config.vim.notify.nvim-notify;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["nvim-notify"]; vim = {
startPlugins = ["nvim-notify"];
vim.luaConfigRC.nvim-notify = nvim.dag.entryAnywhere '' luaConfigRC.nvim-notify = entryAnywhere ''
require('notify').setup { require('notify').setup {
stages = "${cfg.stages}", stages = "${cfg.stages}",
timeout = ${toString cfg.timeout}, timeout = ${toString cfg.timeout},
@ -36,4 +38,5 @@ in {
end end
''; '';
}; };
};
} }

View file

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

View file

@ -1,38 +1,35 @@
{ {lib, ...}: let
config, inherit (lib.options) mkOption mkEnableOption;
lib, inherit (lib.types) enum int str attrsOf;
...
}: let
inherit (lib) mkEnableOption mkOption types;
in { in {
options.vim.notify.nvim-notify = { options.vim.notify.nvim-notify = {
enable = mkEnableOption "nvim-notify notifications"; enable = mkEnableOption "nvim-notify notifications";
stages = mkOption { 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"; default = "fade_in_slide_out";
description = "The stages of the notification"; description = "The stages of the notification";
}; };
timeout = mkOption { timeout = mkOption {
type = types.int; type = int;
default = 1000; default = 1000;
description = "The timeout of the notification"; description = "The timeout of the notification";
}; };
background_colour = mkOption { background_colour = mkOption {
type = types.str; type = str;
default = "#000000"; default = "#000000";
description = "The background colour of the notification"; description = "The background colour of the notification";
}; };
position = mkOption { 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"; default = "top_right";
description = "The position of the notification"; description = "The position of the notification";
}; };
icons = mkOption { icons = mkOption {
type = types.attrsOf types.str; type = attrsOf str;
description = "The icons of the notification"; description = "The icons of the notification";
default = { default = {
ERROR = ""; ERROR = "";

View file

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

View file

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

View file

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