From a7531186a87baac7a3807f5f725c27599b2ac48b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 16 Mar 2024 16:25:30 +0300 Subject: [PATCH] modules/ui: switch to explicit lib calls --- modules/ui/borders/borders.nix | 13 +- modules/ui/borders/default.nix | 2 +- modules/ui/breadcrumbs/breadcrumbs.nix | 205 +++++++++--------- modules/ui/breadcrumbs/config.nix | 38 ++-- modules/ui/breadcrumbs/default.nix | 2 +- modules/ui/colorizer/colorizer.nix | 62 ++---- modules/ui/colorizer/config.nix | 12 +- modules/ui/colorizer/default.nix | 2 +- modules/ui/default.nix | 2 +- modules/ui/illuminate/config.nix | 5 +- modules/ui/illuminate/default.nix | 2 +- modules/ui/illuminate/illuminate.nix | 10 +- modules/ui/modes/config.nix | 6 +- modules/ui/modes/default.nix | 2 +- modules/ui/modes/modes.nix | 24 +- modules/ui/noice/config.nix | 6 +- modules/ui/noice/default.nix | 2 +- modules/ui/noice/noice.nix | 8 +- modules/ui/notifications/default.nix | 2 +- .../ui/notifications/nvim-notify/config.nix | 53 ++--- .../ui/notifications/nvim-notify/default.nix | 2 +- .../notifications/nvim-notify/nvim-notify.nix | 19 +- modules/ui/smartcolumn/config.nix | 31 +-- modules/ui/smartcolumn/default.nix | 2 +- modules/ui/smartcolumn/smartcolumn.nix | 11 +- 25 files changed, 251 insertions(+), 272 deletions(-) diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix index 69d1ccd..fb767ce 100644 --- a/modules/ui/borders/borders.nix +++ b/modules/ui/borders/borders.nix @@ -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"; diff --git a/modules/ui/borders/default.nix b/modules/ui/borders/default.nix index 526ac4e..38b02b8 100644 --- a/modules/ui/borders/default.nix +++ b/modules/ui/borders/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./borders.nix ]; diff --git a/modules/ui/breadcrumbs/breadcrumbs.nix b/modules/ui/breadcrumbs/breadcrumbs.nix index c979e39..68c2a9f 100644 --- a/modules/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/ui/breadcrumbs/breadcrumbs.nix @@ -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 = ""; 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 = ""; 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"; }; }; }; diff --git a/modules/ui/breadcrumbs/config.nix b/modules/ui/breadcrumbs/config.nix index 22de56d..5afda30 100644 --- a/modules/ui/breadcrumbs/config.nix +++ b/modules/ui/breadcrumbs/config.nix @@ -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 = { diff --git a/modules/ui/breadcrumbs/default.nix b/modules/ui/breadcrumbs/default.nix index 02c6351..50feefc 100644 --- a/modules/ui/breadcrumbs/default.nix +++ b/modules/ui/breadcrumbs/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./breadcrumbs.nix diff --git a/modules/ui/colorizer/colorizer.nix b/modules/ui/colorizer/colorizer.nix index 8497e04..de3281c 100644 --- a/modules/ui/colorizer/colorizer.nix +++ b/modules/ui/colorizer/colorizer.nix @@ -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"; }; }; } diff --git a/modules/ui/colorizer/config.nix b/modules/ui/colorizer/config.nix index 2706499..a21644f 100644 --- a/modules/ui/colorizer/config.nix +++ b/modules/ui/colorizer/config.nix @@ -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}; diff --git a/modules/ui/colorizer/default.nix b/modules/ui/colorizer/default.nix index 3b5b491..ef88180 100644 --- a/modules/ui/colorizer/default.nix +++ b/modules/ui/colorizer/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./colorizer.nix ./config.nix diff --git a/modules/ui/default.nix b/modules/ui/default.nix index bbcb9d2..262cdbb 100644 --- a/modules/ui/default.nix +++ b/modules/ui/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./noice ./modes diff --git a/modules/ui/illuminate/config.nix b/modules/ui/illuminate/config.nix index 4377622..6d08c76 100644 --- a/modules/ui/illuminate/config.nix +++ b/modules/ui/illuminate/config.nix @@ -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', diff --git a/modules/ui/illuminate/default.nix b/modules/ui/illuminate/default.nix index 366bb7b..03efe4c 100644 --- a/modules/ui/illuminate/default.nix +++ b/modules/ui/illuminate/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./illuminate.nix diff --git a/modules/ui/illuminate/illuminate.nix b/modules/ui/illuminate/illuminate.nix index 29426f9..c9c5d2f 100644 --- a/modules/ui/illuminate/illuminate.nix +++ b/modules/ui/illuminate/illuminate.nix @@ -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]"; }; } diff --git a/modules/ui/modes/config.nix b/modules/ui/modes/config.nix index d8483af..25ee337 100644 --- a/modules/ui/modes/config.nix +++ b/modules/ui/modes/config.nix @@ -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 = { diff --git a/modules/ui/modes/default.nix b/modules/ui/modes/default.nix index 8c668de..4fb9652 100644 --- a/modules/ui/modes/default.nix +++ b/modules/ui/modes/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./modes.nix ./config.nix diff --git a/modules/ui/modes/modes.nix b/modules/ui/modes/modes.nix index bfa80b0..e49251a 100644 --- a/modules/ui/modes/modes.nix +++ b/modules/ui/modes/modes.nix @@ -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"; }; diff --git a/modules/ui/noice/config.nix b/modules/ui/noice/config.nix index 2355497..63c4f2b 100644 --- a/modules/ui/noice/config.nix +++ b/modules/ui/noice/config.nix @@ -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 = { diff --git a/modules/ui/noice/default.nix b/modules/ui/noice/default.nix index e808738..24f0ab6 100644 --- a/modules/ui/noice/default.nix +++ b/modules/ui/noice/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./noice.nix ./config.nix diff --git a/modules/ui/noice/noice.nix b/modules/ui/noice/noice.nix index 7afe82c..df4ce85 100644 --- a/modules/ui/noice/noice.nix +++ b/modules/ui/noice/noice.nix @@ -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]"; }; } diff --git a/modules/ui/notifications/default.nix b/modules/ui/notifications/default.nix index aa5a73b..d1bd989 100644 --- a/modules/ui/notifications/default.nix +++ b/modules/ui/notifications/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-notify ]; diff --git a/modules/ui/notifications/nvim-notify/config.nix b/modules/ui/notifications/nvim-notify/config.nix index d291366..c2c4991 100644 --- a/modules/ui/notifications/nvim-notify/config.nix +++ b/modules/ui/notifications/nvim-notify/config.nix @@ -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 - ''; + ''; + }; }; } diff --git a/modules/ui/notifications/nvim-notify/default.nix b/modules/ui/notifications/nvim-notify/default.nix index 0d4c39d..d14648b 100644 --- a/modules/ui/notifications/nvim-notify/default.nix +++ b/modules/ui/notifications/nvim-notify/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./nvim-notify.nix diff --git a/modules/ui/notifications/nvim-notify/nvim-notify.nix b/modules/ui/notifications/nvim-notify/nvim-notify.nix index 0374114..ab78d45 100644 --- a/modules/ui/notifications/nvim-notify/nvim-notify.nix +++ b/modules/ui/notifications/nvim-notify/nvim-notify.nix @@ -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 = ""; diff --git a/modules/ui/smartcolumn/config.nix b/modules/ui/smartcolumn/config.nix index 5cf7b74..3f4ae05 100644 --- a/modules/ui/smartcolumn/config.nix +++ b/modules/ui/smartcolumn/config.nix @@ -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", + }) + ''; + }; }; } diff --git a/modules/ui/smartcolumn/default.nix b/modules/ui/smartcolumn/default.nix index 2169b22..baa85ba 100644 --- a/modules/ui/smartcolumn/default.nix +++ b/modules/ui/smartcolumn/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./smartcolumn.nix ./config.nix diff --git a/modules/ui/smartcolumn/smartcolumn.nix b/modules/ui/smartcolumn/smartcolumn.nix index a105463..fe578be 100644 --- a/modules/ui/smartcolumn/smartcolumn.nix +++ b/modules/ui/smartcolumn/smartcolumn.nix @@ -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 ''