From c3533296201171cd85aa834d6d095c16cc5d9562 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 22 Oct 2023 01:22:31 +0300 Subject: [PATCH] modules/visuals: add highlight-undo a plugin for highlighting undo/redo targets --- configuration.nix | 5 ++++- flake.nix | 5 +++++ lib/types/plugins.nix | 1 + modules/visuals/config.nix | 25 +++++++++++++++++++++++++ modules/visuals/visuals.nix | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 86e5faf..36816eb 100644 --- a/configuration.nix +++ b/configuration.nix @@ -79,14 +79,17 @@ inputs: let nvimWebDevicons.enable = true; scrollBar.enable = true; smoothScroll.enable = true; - cellularAutomaton.enable = isMaximal; + cellularAutomaton.enable = false; fidget-nvim.enable = true; + highlight-undo.enable = true; + indentBlankline = { enable = true; fillChar = null; eolChar = null; showCurrContext = true; }; + cursorline = { enable = true; lineTimeout = 0; diff --git a/flake.nix b/flake.nix index 914dc5c..ca96dda 100644 --- a/flake.nix +++ b/flake.nix @@ -368,6 +368,11 @@ flake = false; }; + highlight-undo = { + url = "github:tzachar/highlight-undo.nvim"; + flake = false; + }; + # Markdown glow-nvim = { url = "github:ellisonleao/glow.nvim"; diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index b189503..dcc5f79 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -94,6 +94,7 @@ with lib; let "copilot-cmp" "lsp-lines" "vim-dirtytalk" + "highlight-undo" ]; # You can either use the name of the plugin or a package. pluginType = with types; diff --git a/modules/visuals/config.nix b/modules/visuals/config.nix index 703f4dc..ab580ca 100644 --- a/modules/visuals/config.nix +++ b/modules/visuals/config.nix @@ -118,5 +118,30 @@ in { } ''; }) + + (mkIf cfg.highlight-undo.enable { + vim.startPlugins = ["highlight-undo"]; + vim.luaConfigRC.fidget-nvim = nvim.dag.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/visuals/visuals.nix b/modules/visuals/visuals.nix index 0b7fd9e..41d2bdc 100644 --- a/modules/visuals/visuals.nix +++ b/modules/visuals/visuals.nix @@ -103,5 +103,40 @@ in { defaultText = literalExpression "config.vim.treesitter.enable"; }; }; + + highlight-undo = { + enable = mkEnableOption "highlight undo [highlight-undo]"; + + highlightForCount = mkOption { + type = types.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 = types.int; + description = "Duration of highlight"; + default = 200; + }; + + undo = { + hlGroup = mkOption { + type = types.str; + description = "Highlight group for undo"; + default = "HighlightUndo"; + }; + }; + + redo = { + hlGroup = mkOption { + type = types.str; + description = "Highlight group for redo"; + default = "HighlightUndo"; + }; + }; + }; }; }