From d3cd9809b25f86c03780b59073c5c04d7d9cbd73 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:12:01 +0200 Subject: [PATCH 1/5] ui: allow custom listOf str border type --- modules/plugins/lsp/lspconfig/config.nix | 3 ++- modules/plugins/lsp/nvim-code-action-menu/config.nix | 3 ++- modules/plugins/ui/borders/borders.nix | 6 +++--- modules/plugins/ui/breadcrumbs/breadcrumbs.nix | 10 +++++----- modules/plugins/utility/binds/which-key/config.nix | 2 +- modules/plugins/visuals/fidget/fidget.nix | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/plugins/lsp/lspconfig/config.nix b/modules/plugins/lsp/lspconfig/config.nix index 1736ce9..2123d32 100644 --- a/modules/plugins/lsp/lspconfig/config.nix +++ b/modules/plugins/lsp/lspconfig/config.nix @@ -7,6 +7,7 @@ inherit (lib.strings) optionalString; inherit (lib.attrsets) mapAttrs; inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.lsp; in { @@ -22,7 +23,7 @@ in { ${ optionalString config.vim.ui.borders.enable '' - require('lspconfig.ui.windows').default_options.border = '${config.vim.ui.borders.globalStyle}' + require('lspconfig.ui.windows').default_options.border = ${toLuaObject config.vim.ui.borders.globalStyle} '' } ''; diff --git a/modules/plugins/lsp/nvim-code-action-menu/config.nix b/modules/plugins/lsp/nvim-code-action-menu/config.nix index e55fb4a..79e16ce 100644 --- a/modules/plugins/lsp/nvim-code-action-menu/config.nix +++ b/modules/plugins/lsp/nvim-code-action-menu/config.nix @@ -6,6 +6,7 @@ inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings pushDownDefault; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.lsp; @@ -25,7 +26,7 @@ in { luaConfigRC.code-action-menu = entryAnywhere '' -- border configuration - vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' + vim.g.code_action_menu_window_border = ${toLuaObject config.vim.ui.borders.plugins.code-action-menu.style} -- show individual sections of the code action menu ${lib.optionalString cfg.nvimCodeActionMenu.show.details "vim.g.code_action_menu_show_details = true"} diff --git a/modules/plugins/ui/borders/borders.nix b/modules/plugins/ui/borders/borders.nix index 37589dc..4abb130 100644 --- a/modules/plugins/ui/borders/borders.nix +++ b/modules/plugins/ui/borders/borders.nix @@ -5,7 +5,7 @@ }: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.lists) optionals; - inherit (lib.types) enum; + inherit (lib.types) enum either listOf str; cfg = config.vim.ui.borders; @@ -15,7 +15,7 @@ in { enable = mkEnableOption "visible borders for most windows"; globalStyle = mkOption { - type = enum defaultStyles; + type = either (enum defaultStyles) (listOf str); default = "rounded"; description = '' The global border style to use. @@ -28,7 +28,7 @@ in { enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;}; style = mkOption { - type = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]); + type = either (enum (defaultStyles ++ optionals (name != "which-key") ["shadow"])) (listOf str); default = cfg.globalStyle; description = "The border style to use for the ${name} plugin"; }; diff --git a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix index 18df8c0..8f246b3 100644 --- a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix @@ -4,7 +4,7 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) nullOr listOf enum bool str int; + inherit (lib.types) nullOr listOf enum bool str int either; inherit (lib.modules) mkRenamedOptionModule; inherit (lib.nvim.types) mkPluginSetupOption; mkSimpleIconOption = default: @@ -213,7 +213,7 @@ in { border = mkOption { # TODO: let this type accept a custom string - type = enum ["single" "rounded" "double" "solid" "none"]; + type = either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str); default = config.vim.ui.borders.globalStyle; description = "border style to use"; }; @@ -237,7 +237,7 @@ in { border = mkOption { # TODO: let this type accept a custom string - type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); + type = nullOr (either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str)); default = config.vim.ui.borders.globalStyle; description = "border style to use for the left section of Navbuddy UI"; }; @@ -255,7 +255,7 @@ in { border = mkOption { # TODO: let this type accept a custom string - type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); + type = nullOr (either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str)); default = config.vim.ui.borders.globalStyle; description = "border style to use for the middle section of Navbuddy UI"; }; @@ -266,7 +266,7 @@ in { right = { border = mkOption { # TODO: let this type accept a custom string - type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); + type = nullOr (either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str)); default = config.vim.ui.borders.globalStyle; description = "border style to use for the right section of Navbuddy UI"; }; diff --git a/modules/plugins/utility/binds/which-key/config.nix b/modules/plugins/utility/binds/which-key/config.nix index e6aa2d9..3535289 100644 --- a/modules/plugins/utility/binds/which-key/config.nix +++ b/modules/plugins/utility/binds/which-key/config.nix @@ -25,7 +25,7 @@ in { ${optionalString config.vim.ui.borders.plugins.which-key.enable '' window = { - border = "${config.vim.ui.borders.plugins.which-key.style}", + border = ${toLuaObject config.vim.ui.borders.plugins.which-key.style}, }, ''} }) diff --git a/modules/plugins/visuals/fidget/fidget.nix b/modules/plugins/visuals/fidget/fidget.nix index c5f4eb6..b77f42c 100644 --- a/modules/plugins/visuals/fidget/fidget.nix +++ b/modules/plugins/visuals/fidget/fidget.nix @@ -6,7 +6,7 @@ inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.strings) toUpper; - inherit (lib.types) int float bool str enum listOf attrsOf oneOf nullOr submodule; + inherit (lib.types) int float bool str enum listOf attrsOf oneOf nullOr submodule either; inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.generators) mkLuaInline; in { @@ -453,7 +453,7 @@ in { }; border = mkOption { description = "Border style of the notification window"; - type = enum ["none" "single" "double" "rounded" "solid" "shadow"]; + type = either (enum ["none" "single" "double" "rounded" "solid" "shadow"]) (listOf str); default = if config.vim.ui.borders.enable then config.vim.ui.borders.globalStyle From 32eb9c3de6e3a3c2b39fffc6eb960ae8a68a03ff Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:56:48 +0200 Subject: [PATCH 2/5] lib: extract shared borderType --- lib/types/default.nix | 2 +- lib/types/plugins.nix | 4 ++++ modules/plugins/ui/borders/borders.nix | 14 ++++++++------ modules/plugins/ui/breadcrumbs/breadcrumbs.nix | 14 +++++--------- modules/plugins/visuals/fidget/fidget.nix | 6 +++--- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/types/default.nix b/lib/types/default.nix index 928bbae..6751229 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -9,7 +9,7 @@ typesCustom = import ./custom.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType; inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesCustom) anythingConcatLists char; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index c0e89d6..65ba49b 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -51,9 +51,13 @@ }; }; }; + + borderPresets = ["none" "single" "double" "rounded" "solid" "shadow"]; in { inherit extraPluginType fromInputs pluginType; + borderType = either (enum borderPresets) (listOf str); + pluginsOpt = { description, example, diff --git a/modules/plugins/ui/borders/borders.nix b/modules/plugins/ui/borders/borders.nix index 4abb130..8a295fc 100644 --- a/modules/plugins/ui/borders/borders.nix +++ b/modules/plugins/ui/borders/borders.nix @@ -4,22 +4,24 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.lists) optionals; - inherit (lib.types) enum either listOf str; + inherit (lib.nvim.types) borderType; cfg = config.vim.ui.borders; - - defaultStyles = ["none" "single" "double" "rounded"]; in { options.vim.ui.borders = { enable = mkEnableOption "visible borders for most windows"; globalStyle = mkOption { - type = either (enum defaultStyles) (listOf str); + type = borderType; default = "rounded"; description = '' The global border style to use. + + If a list is given, it should have a length of eight or any divisor of + eight. The array will specify the eight chars building up the border in + a clockwise fashion starting with the top-left corner. ''; + example = ["╔" "═" "╗" "║" "╝" "═" "╚" "║"]; }; # TODO: make per-plugin borders configurable @@ -28,7 +30,7 @@ in { enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;}; style = mkOption { - type = either (enum (defaultStyles ++ optionals (name != "which-key") ["shadow"])) (listOf str); + type = borderType; default = cfg.globalStyle; description = "The border style to use for the ${name} plugin"; }; diff --git a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix index 8f246b3..e173688 100644 --- a/modules/plugins/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/plugins/ui/breadcrumbs/breadcrumbs.nix @@ -6,7 +6,7 @@ inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) nullOr listOf enum bool str int either; inherit (lib.modules) mkRenamedOptionModule; - inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.nvim.types) mkPluginSetupOption borderType; mkSimpleIconOption = default: mkOption { inherit default; @@ -212,8 +212,7 @@ in { # position = {} border = mkOption { - # TODO: let this type accept a custom string - type = either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str); + type = borderType; default = config.vim.ui.borders.globalStyle; description = "border style to use"; }; @@ -236,8 +235,7 @@ in { */ border = mkOption { - # TODO: let this type accept a custom string - type = nullOr (either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str)); + type = borderType; default = config.vim.ui.borders.globalStyle; description = "border style to use for the left section of Navbuddy UI"; }; @@ -254,8 +252,7 @@ in { */ border = mkOption { - # TODO: let this type accept a custom string - type = nullOr (either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str)); + type = borderType; default = config.vim.ui.borders.globalStyle; description = "border style to use for the middle section of Navbuddy UI"; }; @@ -265,8 +262,7 @@ in { # there is no size option for the right section, it fills the remaining space right = { border = mkOption { - # TODO: let this type accept a custom string - type = nullOr (either (enum ["single" "rounded" "double" "solid" "none"]) (listOf str)); + type = borderType; default = config.vim.ui.borders.globalStyle; description = "border style to use for the right section of Navbuddy UI"; }; diff --git a/modules/plugins/visuals/fidget/fidget.nix b/modules/plugins/visuals/fidget/fidget.nix index b77f42c..79974bd 100644 --- a/modules/plugins/visuals/fidget/fidget.nix +++ b/modules/plugins/visuals/fidget/fidget.nix @@ -6,8 +6,8 @@ inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.strings) toUpper; - inherit (lib.types) int float bool str enum listOf attrsOf oneOf nullOr submodule either; - inherit (lib.nvim.types) mkPluginSetupOption luaInline; + inherit (lib.types) int float bool str enum listOf attrsOf oneOf nullOr submodule; + inherit (lib.nvim.types) mkPluginSetupOption luaInline borderType; inherit (lib.generators) mkLuaInline; in { imports = [ @@ -453,7 +453,7 @@ in { }; border = mkOption { description = "Border style of the notification window"; - type = either (enum ["none" "single" "double" "rounded" "solid" "shadow"]) (listOf str); + type = borderType; default = if config.vim.ui.borders.enable then config.vim.ui.borders.globalStyle From 5c9746aa302c084c3ea1bb4534725327d8ad7a4c Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:58:02 +0200 Subject: [PATCH 3/5] remove TODO --- modules/plugins/ui/borders/borders.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/plugins/ui/borders/borders.nix b/modules/plugins/ui/borders/borders.nix index 8a295fc..3097530 100644 --- a/modules/plugins/ui/borders/borders.nix +++ b/modules/plugins/ui/borders/borders.nix @@ -24,7 +24,6 @@ in { example = ["╔" "═" "╗" "║" "╝" "═" "╚" "║"]; }; - # TODO: make per-plugin borders configurable plugins = let mkPluginStyleOption = name: { enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;}; From de19f0249a40bcd854e1d844034b62d33ebe71ec Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:48:56 +0200 Subject: [PATCH 4/5] allow ["|" "HighlightGroup"] for border char --- lib/types/plugins.nix | 2 +- modules/plugins/ui/borders/borders.nix | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 65ba49b..7d24163 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -56,7 +56,7 @@ in { inherit extraPluginType fromInputs pluginType; - borderType = either (enum borderPresets) (listOf str); + borderType = either (enum borderPresets) (listOf (either str (listOf str))); pluginsOpt = { description, diff --git a/modules/plugins/ui/borders/borders.nix b/modules/plugins/ui/borders/borders.nix index 3097530..9951591 100644 --- a/modules/plugins/ui/borders/borders.nix +++ b/modules/plugins/ui/borders/borders.nix @@ -19,7 +19,9 @@ in { If a list is given, it should have a length of eight or any divisor of eight. The array will specify the eight chars building up the border in - a clockwise fashion starting with the top-left corner. + a clockwise fashion starting with the top-left corner. You can specify + a different highlight group for each character by passing a + [char, "YourHighlightGroup"] instead ''; example = ["╔" "═" "╗" "║" "╝" "═" "╚" "║"]; }; From f7db34b19732888245d095c9cd18a68db816b12c Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:58:30 +0200 Subject: [PATCH 5/5] docs: update rl notes --- docs/release-notes/rl-0.7.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d5f3853..63f5834 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -34,6 +34,7 @@ Release notes for release 0.7 longer filtered and thus should be used instead. - Add dap-go for better dap configurations - Make noice.nvim customizable +- Standardize border style options and add custom borders [jacekpoz](https://github.com/jacekpoz):