Merge pull request #170 from NotAShelf/highlight-undo

modules/visuals: add highlight-undo
This commit is contained in:
NotAShelf 2023-10-22 02:03:09 +03:00 committed by GitHub
commit 29de5b56c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 105 additions and 15 deletions

View file

@ -79,14 +79,17 @@ inputs: let
nvimWebDevicons.enable = true; nvimWebDevicons.enable = true;
scrollBar.enable = true; scrollBar.enable = true;
smoothScroll.enable = true; smoothScroll.enable = true;
cellularAutomaton.enable = isMaximal; cellularAutomaton.enable = false;
fidget-nvim.enable = true; fidget-nvim.enable = true;
highlight-undo.enable = true;
indentBlankline = { indentBlankline = {
enable = true; enable = true;
fillChar = null; fillChar = null;
eolChar = null; eolChar = null;
showCurrContext = true; showCurrContext = true;
}; };
cursorline = { cursorline = {
enable = true; enable = true;
lineTimeout = 0; lineTimeout = 0;

View file

@ -6,27 +6,27 @@
=== Changelog === Changelog
https://github.com/vagahbond[vagahbond]: 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]: 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>> * 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]: 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]: https://github.com/yavko[yavko]:
@ -36,9 +36,9 @@ https://github.com/yavko[yavko]:
https://github.com/FrothyMarrow[frothymarrow]: 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]: https://github.com/notashelf[notashelf]:
@ -60,7 +60,9 @@ https://github.com/notashelf[notashelf]:
* Added a configuration option for choosing the leader key * 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]: https://github.com/jacekpoz[jacekpoz]:
@ -75,3 +77,5 @@ https://github.com/ksonj[ksonj]:
* Add support to change mappings to utility/surround * Add support to change mappings to utility/surround
* Add black-and-isort python formatter * Add black-and-isort python formatter
* Removed redundant "Enable ..." in `mkEnableOption` descriptions

View file

@ -533,6 +533,22 @@
"type": "github" "type": "github"
} }
}, },
"highlight-undo": {
"flake": false,
"locked": {
"lastModified": 1695227852,
"narHash": "sha256-I1AwVYqpJNA3K1AwGy/VgPnbrYvX19qfI9bQFZNu1SU=",
"owner": "tzachar",
"repo": "highlight-undo.nvim",
"rev": "50a6884a8476be04ecce8f1c4ed692c5000ef0a1",
"type": "github"
},
"original": {
"owner": "tzachar",
"repo": "highlight-undo.nvim",
"type": "github"
}
},
"hop-nvim": { "hop-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -804,11 +820,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1696879762, "lastModified": 1697723726,
"narHash": "sha256-Ud6bH4DMcYHUDKavNMxAhcIpDGgHMyL/yaDEAVSImQY=", "narHash": "sha256-SaTWPkI8a5xSHX/rrKzUe+/uVNy6zCGMXgoeMb7T9rg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f99e5f03cc0aa231ab5950a15ed02afec45ed51a", "rev": "7c9cc5a6e5d38010801741ac830a3f8fd667a7a0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1465,6 +1481,7 @@
"gesture-nvim": "gesture-nvim", "gesture-nvim": "gesture-nvim",
"gitsigns-nvim": "gitsigns-nvim", "gitsigns-nvim": "gitsigns-nvim",
"glow-nvim": "glow-nvim", "glow-nvim": "glow-nvim",
"highlight-undo": "highlight-undo",
"hop-nvim": "hop-nvim", "hop-nvim": "hop-nvim",
"icon-picker-nvim": "icon-picker-nvim", "icon-picker-nvim": "icon-picker-nvim",
"indent-blankline": "indent-blankline", "indent-blankline": "indent-blankline",

View file

@ -368,6 +368,11 @@
flake = false; flake = false;
}; };
highlight-undo = {
url = "github:tzachar/highlight-undo.nvim";
flake = false;
};
# Markdown # Markdown
glow-nvim = { glow-nvim = {
url = "github:ellisonleao/glow.nvim"; url = "github:ellisonleao/glow.nvim";

View file

@ -94,6 +94,7 @@ with lib; let
"copilot-cmp" "copilot-cmp"
"lsp-lines" "lsp-lines"
"vim-dirtytalk" "vim-dirtytalk"
"highlight-undo"
]; ];
# You can either use the name of the plugin or a package. # You can either use the name of the plugin or a package.
pluginType = with types; pluginType = with types;

View file

@ -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 = {}
},
})
'';
})
]); ]);
} }

View file

@ -103,5 +103,40 @@ in {
defaultText = literalExpression "config.vim.treesitter.enable"; 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";
};
};
};
}; };
} }