From 0e84e4ebed49758f36d192397212cd21a06ad366 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 1 May 2024 21:46:42 +0300 Subject: [PATCH 1/4] modules/plugins: move plugins/ui to neovim/global/ui --- modules/modules.nix | 1 + modules/neovim/global/default.nix | 6 ++++++ .../borders => neovim/global/ui}/borders.nix | 21 ++++++++++--------- modules/plugins/ui/borders/default.nix | 5 ----- modules/plugins/ui/default.nix | 10 ++++----- 5 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 modules/neovim/global/default.nix rename modules/{plugins/ui/borders => neovim/global/ui}/borders.nix (60%) delete mode 100644 modules/plugins/ui/borders/default.nix diff --git a/modules/modules.nix b/modules/modules.nix index a00cea6..2d82f87 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -10,6 +10,7 @@ # Contains configuration for core neovim features # such as spellchecking, mappings, and the init script (init.vim). neovim = map (p: ./neovim + "/${p}") [ + "global" "init" "mappings" ]; diff --git a/modules/neovim/global/default.nix b/modules/neovim/global/default.nix new file mode 100644 index 0000000..94b5788 --- /dev/null +++ b/modules/neovim/global/default.nix @@ -0,0 +1,6 @@ +{lib}: { + imports = lib.concatLists [ + # Configuration options for Neovim UI + (lib.filesystem.listFilesRecursive ./ui) + ]; +} diff --git a/modules/plugins/ui/borders/borders.nix b/modules/neovim/global/ui/borders.nix similarity index 60% rename from modules/plugins/ui/borders/borders.nix rename to modules/neovim/global/ui/borders.nix index 37589dc..7021301 100644 --- a/modules/plugins/ui/borders/borders.nix +++ b/modules/neovim/global/ui/borders.nix @@ -4,6 +4,7 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; + inherit (lib.attrsets) mapAttrs; inherit (lib.lists) optionals; inherit (lib.types) enum; @@ -22,7 +23,6 @@ in { ''; }; - # TODO: make per-plugin borders configurable plugins = let mkPluginStyleOption = name: { enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;}; @@ -33,14 +33,15 @@ in { 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 - # 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"; - lsp-signature = mkPluginStyleOption "lsp-signature"; - code-action-menu = mkPluginStyleOption "code-actions-menu"; - }; + in + mapAttrs (_: mkPluginStyleOption) { + # despite not having it listed in example configuration, which-key does support the rounded type + # 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"; + lsp-signature = mkPluginStyleOption "lsp-signature"; + code-action-menu = mkPluginStyleOption "code-actions-menu"; + }; }; } diff --git a/modules/plugins/ui/borders/default.nix b/modules/plugins/ui/borders/default.nix deleted file mode 100644 index 38b02b8..0000000 --- a/modules/plugins/ui/borders/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./borders.nix - ]; -} diff --git a/modules/plugins/ui/default.nix b/modules/plugins/ui/default.nix index 262cdbb..8bb7309 100644 --- a/modules/plugins/ui/default.nix +++ b/modules/plugins/ui/default.nix @@ -1,12 +1,10 @@ { imports = [ - ./noice - ./modes - ./notifications - ./smartcolumn + ./breadcumbs ./colorizer ./illuminate - ./breadcrumbs - ./borders + ./noice + ./notifications + ./smartcolumn ]; } From 754c29cb7c06b6b611b1b81e7ffcf354eb801054 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 1 May 2024 22:00:24 +0300 Subject: [PATCH 2/4] neovim/global: add ui/icons --- modules/neovim/global/ui/icons.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 modules/neovim/global/ui/icons.nix diff --git a/modules/neovim/global/ui/icons.nix b/modules/neovim/global/ui/icons.nix new file mode 100644 index 0000000..76c1e3c --- /dev/null +++ b/modules/neovim/global/ui/icons.nix @@ -0,0 +1,30 @@ +{lib, ...}: let + inherit (lib.options) mkOption; + inherit (lib.types) str; +in { + options.vim.ui.icons = { + ERROR = mkOption { + type = str; + default = " "; + description = "The icon to use for error messages"; + }; + + WARN = mkOption { + type = str; + default = " "; + description = "The icon to use for warning messages"; + }; + + INFO = mkOption { + type = str; + default = " "; + description = "The icon to use for info messages"; + }; + + HINT = mkOption { + type = str; + default = " "; + description = "The icon to use for hint messages"; + }; + }; +} From cb57d3d417fb6055f243bc4b6025380b7233170a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 May 2024 19:02:37 +0300 Subject: [PATCH 3/4] plugins/ui: re-organize imports --- modules/plugins/ui/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/plugins/ui/default.nix b/modules/plugins/ui/default.nix index 8bb7309..214e09f 100644 --- a/modules/plugins/ui/default.nix +++ b/modules/plugins/ui/default.nix @@ -1,8 +1,9 @@ { imports = [ - ./breadcumbs + ./breadcrumbs ./colorizer ./illuminate + ./modes ./noice ./notifications ./smartcolumn From 7d077f43f72f959c84fe02e0d2141d3268dc767c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 May 2024 19:03:05 +0300 Subject: [PATCH 4/4] neovim/global: begin adding `vim.diagnostics.config()` options --- modules/neovim/global/default.nix | 12 ++- modules/neovim/global/diagnostics.nix | 115 ++++++++++++++++++++++++++ modules/neovim/global/ui/borders.nix | 20 +++-- modules/neovim/global/ui/icons.nix | 40 ++++----- 4 files changed, 157 insertions(+), 30 deletions(-) create mode 100644 modules/neovim/global/diagnostics.nix diff --git a/modules/neovim/global/default.nix b/modules/neovim/global/default.nix index 94b5788..bbb0c42 100644 --- a/modules/neovim/global/default.nix +++ b/modules/neovim/global/default.nix @@ -1,6 +1,12 @@ -{lib}: { - imports = lib.concatLists [ +{lib, ...}: let + inherit (lib.lists) concatLists; + inherit (lib.filesystem) listFilesRecursive; +in { + imports = concatLists [ # Configuration options for Neovim UI - (lib.filesystem.listFilesRecursive ./ui) + (listFilesRecursive ./ui) + + # vim.diagnostics + [./diagnostics.nix] ]; } diff --git a/modules/neovim/global/diagnostics.nix b/modules/neovim/global/diagnostics.nix new file mode 100644 index 0000000..bac4611 --- /dev/null +++ b/modules/neovim/global/diagnostics.nix @@ -0,0 +1,115 @@ +{ + config, + lib, + ... +}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) str bool enum either; +in { + options.vim.diagnostics = { + virtual_text = mkOption { + type = bool; + default = true; + description = '' + Whether to use virtual text for diagnostics. + + If multiple diagnostics are set for a namespace, one + prefix per diagnostic + the last diagnostic message + are shown. + ''; + }; + + update_in_insert = mkOption { + type = bool; + default = false; + description = '' + Whether to update diagnostics in insert mode. + + This is useful for slow diagnostics sources, but can + also cause lag in insert mode. + ''; + }; + + underline = mkOption { + type = bool; + default = true; + description = '' + Whether to underline diagnostics. + ''; + }; + + severity_sort = mkOption { + type = bool; + default = false; + description = '' + Whether to sort diagnostics by severity. + + This affects the order in which signs and + virtual text are displayed. When true, higher + severities are displayed before lower severities (e.g. + ERROR is displayed before WARN) + ''; + }; + + float = { + focusable = mkOption { + type = bool; + default = false; + description = '' + Whether the floating window is focusable. + When true, the floating window can be focused and + interacted with. When false, the floating window is + not focusable and will not receive input. + ''; + }; + + border = mkOption { + type = enum ["none" "single" "double" "rounded" "solid" "shadow"]; + default = config.vim.ui.border.globalStyle; + description = '' + The border style of the floating window. + + Possible values: + - none + - single + - double + - rounded + - solid + - shadow + + See `:h nvim_open_win` for the available border + styles and their definitions. + ''; + }; + + source = mkOption { + type = either bool (enum ["always" "if_many"]); + default = "auto"; + description = '' + The source of the floating window. + Possible values: + - auto: Use the same source as the diagnostics + window. + - window: Use the window source. + - buffer: Use the buffer source. + ''; + }; + + prefix = mkOption { + type = str; + default = ""; + description = '' + Prefix string for each diagnostic in the floating window + ''; + }; + + suffix = mkOption { + type = str; + default = ""; + description = '' + Suffix string for each diagnostic in the floating window + ''; + }; + }; + }; +} diff --git a/modules/neovim/global/ui/borders.nix b/modules/neovim/global/ui/borders.nix index 7021301..f40dbd0 100644 --- a/modules/neovim/global/ui/borders.nix +++ b/modules/neovim/global/ui/borders.nix @@ -10,14 +10,18 @@ cfg = config.vim.ui.borders; - defaultStyles = ["none" "single" "double" "rounded"]; + # See `:h nvim_open_win` for the available border styles + # this list can be updated if additional styles are added. + defaultStyles = ["none" "single" "double" "rounded" "solid" "shadow"]; in { options.vim.ui.borders = { - enable = mkEnableOption "visible borders for most windows"; + enable = mkEnableOption "visible borders for windows that support configurable borders"; + # TODO: support configurable border elements with a lua table converted from a list of str + # e.g. [ "╔" "═" "╗" "║" "╝" "═" "╚" "║" ] globalStyle = mkOption { type = enum defaultStyles; - default = "rounded"; + default = "single"; description = '' The global border style to use. ''; @@ -37,11 +41,11 @@ in { mapAttrs (_: mkPluginStyleOption) { # despite not having it listed in example configuration, which-key does support the rounded type # 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"; - lsp-signature = mkPluginStyleOption "lsp-signature"; - code-action-menu = mkPluginStyleOption "code-actions-menu"; + which-key = "which-key"; + lspsaga = "lspsaga"; + nvim-cmp = "nvim-cmp"; + lsp-signature = "lsp-signature"; + code-action-menu = "code-actions-menu"; }; }; } diff --git a/modules/neovim/global/ui/icons.nix b/modules/neovim/global/ui/icons.nix index 76c1e3c..710fb96 100644 --- a/modules/neovim/global/ui/icons.nix +++ b/modules/neovim/global/ui/icons.nix @@ -3,28 +3,30 @@ inherit (lib.types) str; in { options.vim.ui.icons = { - ERROR = mkOption { - type = str; - default = " "; - description = "The icon to use for error messages"; - }; + diagnostics = { + ERROR = mkOption { + type = str; + default = " "; + description = "The icon to use for error messages"; + }; - WARN = mkOption { - type = str; - default = " "; - description = "The icon to use for warning messages"; - }; + WARN = mkOption { + type = str; + default = " "; + description = "The icon to use for warning messages"; + }; - INFO = mkOption { - type = str; - default = " "; - description = "The icon to use for info messages"; - }; + INFO = mkOption { + type = str; + default = " "; + description = "The icon to use for info messages"; + }; - HINT = mkOption { - type = str; - default = " "; - description = "The icon to use for hint messages"; + HINT = mkOption { + type = str; + default = " "; + description = "The icon to use for hint messages"; + }; }; }; }