Skip to content

Commit

Permalink
Merge pull request #170 from NotAShelf/highlight-undo
Browse files Browse the repository at this point in the history
modules/visuals: add highlight-undo
  • Loading branch information
NotAShelf authored Oct 21, 2023
2 parents d7cf84c + b358bfd commit 29de5b5
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 15 deletions.
5 changes: 4 additions & 1 deletion configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 15 additions & 11 deletions docs/release-notes/rl-0.5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
=== Changelog

https://github.com/vagahbond[vagahbond]:
* Added phan language server for PHP.
* Added phan language server for PHP

* Added phpactor language server for PHP.
* Added phpactor language server for PHP

https://github.com/horriblename[horriblename]:

* Added transparency support for tokyonight theme.
* Added transparency support for tokyonight theme

* Fixed a bug where cmp's close and scrollDocs mappings wasn't working.
* Fixed a bug where cmp's close and scrollDocs mappings wasn't working

* Streamlined and simplified extra plugin API with the addition of <<opt-vim.extraPlugins>>

* Allow using command names in place of LSP packages to avoid automatic installation.
* Allow using command names in place of LSP packages to avoid automatic installation

* Add lua LSP and treesitter support, and neodev.nvim plugin support.
* Add lua LSP and treesitter support, and neodev.nvim plugin support

https://github.com/amanse[amanse]:

* Added daily notes options for obsidian plugin.
* Added daily notes options for obsidian plugin

* Added jdt-language-server for Java.
* Added jdt-language-server for Java

https://github.com/yavko[yavko]:

Expand All @@ -36,9 +36,9 @@ https://github.com/yavko[yavko]:

https://github.com/FrothyMarrow[frothymarrow]:

* Renamed `vim.visuals.cursorWordline` to <<opt-vim.visuals.cursorline.enable>>.
* Renamed `vim.visuals.cursorWordline` to <<opt-vim.visuals.cursorline.enable>>

* Added <<opt-vim.visuals.cursorline.lineNumbersOnly>> to display cursorline only in the presence of line numbers.
* Added <<opt-vim.visuals.cursorline.lineNumbersOnly>> to display cursorline only in the presence of line numbers

https://github.com/notashelf[notashelf]:

Expand All @@ -60,7 +60,9 @@ https://github.com/notashelf[notashelf]:

* Added a configuration option for choosing the leader key

* The package used for neovim is now customizable by the user, using <<opt-vim.package>>. For best results, always use an unwrapped package.
* The package used for neovim is now customizable by the user, using <<opt-vim.package>>. For best results, always use an unwrapped package

* Added highlight-undo plugin for highlighting undo/redo targets

https://github.com/jacekpoz[jacekpoz]:

Expand All @@ -75,3 +77,5 @@ https://github.com/ksonj[ksonj]:
* Add support to change mappings to utility/surround

* Add black-and-isort python formatter

* Removed redundant "Enable ..." in `mkEnableOption` descriptions
23 changes: 20 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@
flake = false;
};

highlight-undo = {
url = "github:tzachar/highlight-undo.nvim";
flake = false;
};

# Markdown
glow-nvim = {
url = "github:ellisonleao/glow.nvim";
Expand Down
1 change: 1 addition & 0 deletions lib/types/plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 25 additions & 0 deletions modules/visuals/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<C-r>',
map = 'redo',
opts = {}
},
})
'';
})
]);
}
35 changes: 35 additions & 0 deletions modules/visuals/visuals.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = nvim.nmd.literalAsciiDoc ''
Enable support for highlighting when a <count> is provided before the key
If set to false it will only highlight when the mapping is not prefixed with a <count>
'';
};

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";
};
};
};
};
}

0 comments on commit 29de5b5

Please sign in to comment.