From 901038145d8b10de73732fb4888902a20580a5ae Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 03:00:01 +0300 Subject: [PATCH] visuals: move highlight-undo to its own module; deprecate old opts Upstream cucked us. --- modules/plugins/visuals/config.nix | 47 ------------------ modules/plugins/visuals/default.nix | 13 +++-- .../plugins/visuals/highlight-undo/config.nix | 21 ++++++++ .../visuals/highlight-undo/default.nix | 6 +++ .../visuals/highlight-undo/highlight-undo.nix | 32 ++++++++++++ modules/plugins/visuals/visuals.nix | 49 ------------------- 6 files changed, 68 insertions(+), 100 deletions(-) delete mode 100644 modules/plugins/visuals/config.nix create mode 100644 modules/plugins/visuals/highlight-undo/config.nix create mode 100644 modules/plugins/visuals/highlight-undo/default.nix create mode 100644 modules/plugins/visuals/highlight-undo/highlight-undo.nix delete mode 100644 modules/plugins/visuals/visuals.nix diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix deleted file mode 100644 index 79222fb..0000000 --- a/modules/plugins/visuals/config.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.trivial) boolToString; - inherit (lib.nvim.binds) mkBinding; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.lua) toLuaObject; - - cfg = config.vim.visuals; -in { - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.smoothScroll.enable { - vim.startPlugins = ["cinnamon-nvim"]; - vim.pluginRC.smoothScroll = entryAnywhere '' - require('cinnamon').setup() - ''; - }) - - (mkIf cfg.highlight-undo.enable { - vim.startPlugins = ["highlight-undo"]; - vim.pluginRC.highlight-undo = entryAnywhere '' - require('highlight-undo').setup({ - duration = ${toString cfg.highlight-undo.duration}, - highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount}, - undo = { - hlgroup = ${cfg.highlight-undo.undo.hlGroup}, - mode = 'n', - lhs = 'u', - map = 'undo', - opts = {} - }, - - redo = { - hlgroup = ${cfg.highlight-undo.redo.hlGroup}, - mode = 'n', - lhs = '', - map = 'redo', - opts = {} - }, - }) - ''; - }) - ]); -} diff --git a/modules/plugins/visuals/default.nix b/modules/plugins/visuals/default.nix index 2fecef2..7b413c3 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -1,14 +1,19 @@ -{ +{lib, ...}: let + inherit (lib.modules) mkRemovedOptionModule; +in { imports = [ + (mkRemovedOptionModule ["vim" "visuals" "enable"] '' + As top-level toggles are being deprecated, you are encouraged + to handle plugin toggles under individual options. + '') + ./cellular-automaton ./cinnamon-nvim ./fidget-nvim + ./highlight-undo ./indent-blankline ./nvim-cursorline ./nvim-scrollbar ./nvim-web-devicons - - ./config.nix - ./visuals.nix ]; } diff --git a/modules/plugins/visuals/highlight-undo/config.nix b/modules/plugins/visuals/highlight-undo/config.nix new file mode 100644 index 0000000..d41c6a6 --- /dev/null +++ b/modules/plugins/visuals/highlight-undo/config.nix @@ -0,0 +1,21 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere; + + cfg = config.vim.visuals.highlight-undo; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["highlight-undo"]; + + pluginRC.highlight-undo = entryAnywhere '' + require("highlight-undo").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/visuals/highlight-undo/default.nix b/modules/plugins/visuals/highlight-undo/default.nix new file mode 100644 index 0000000..b862488 --- /dev/null +++ b/modules/plugins/visuals/highlight-undo/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./highlight-undo.nix + ]; +} diff --git a/modules/plugins/visuals/highlight-undo/highlight-undo.nix b/modules/plugins/visuals/highlight-undo/highlight-undo.nix new file mode 100644 index 0000000..fc5d722 --- /dev/null +++ b/modules/plugins/visuals/highlight-undo/highlight-undo.nix @@ -0,0 +1,32 @@ +{lib, ...}: let + inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) int; + inherit (lib.nvim.types) mkPluginSetupOption; + + checkDocsMsg = '' + highlight-undo.nvim has deprecated previously used configuration options in + a recent update, so previous values will no longer work as expected. + + Please use `vim.visuals.highlight-undo.setupOpts` with upstream instructions + ''; +in { + imports = [ + # This gives a lot of error messages for those with default values set or modified. Could + # there be a better way to handle his? Perhaps an assertion? + (mkRemovedOptionModule ["vim" "visuals" "highlight-undo" "highlightForCount"] checkDocsMsg) + (mkRemovedOptionModule ["vim" "visuals" "highlight-undo" "undo" "hlGroup"] checkDocsMsg) + (mkRemovedOptionModule ["vim" "visuals" "highlight-undo" "redo" "hlGroup"] checkDocsMsg) + ]; + + options.vim.visuals.highlight-undo = { + enable = mkEnableOption "highlight undo [highlight-undo]"; + setupOpts = mkPluginSetupOption "highlight-undo" { + duration = mkOption { + type = int; + default = 500; + description = "Duration of the highlight"; + }; + }; + }; +} diff --git a/modules/plugins/visuals/visuals.nix b/modules/plugins/visuals/visuals.nix deleted file mode 100644 index 90558ac..0000000 --- a/modules/plugins/visuals/visuals.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) int bool str; - - cfg = config.vim.visuals; -in { - options.vim.visuals = { - enable = mkEnableOption "Visual enhancements."; - - highlight-undo = { - enable = mkEnableOption "highlight undo [highlight-undo]"; - - highlightForCount = mkOption { - type = bool; - default = true; - description = '' - Enable support for highlighting when a is provided before the key - If set to false it will only highlight when the mapping is not prefixed with a - ''; - }; - - duration = mkOption { - type = int; - description = "Duration of highlight"; - default = 500; - }; - - undo = { - hlGroup = mkOption { - type = str; - description = "Highlight group for undo"; - default = "HighlightUndo"; - }; - }; - - redo = { - hlGroup = mkOption { - type = str; - description = "Highlight group for redo"; - default = "HighlightUndo"; - }; - }; - }; - }; -}