visuals: move highlight-undo to its own module; deprecate old opts

Upstream cucked us.
This commit is contained in:
NotAShelf 2024-10-07 03:00:01 +03:00
parent dad69f8af9
commit 901038145d
No known key found for this signature in database
GPG key ID: AF26552424E53993
6 changed files with 68 additions and 100 deletions

View file

@ -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 = '<C-r>',
map = 'redo',
opts = {}
},
})
'';
})
]);
}

View file

@ -1,14 +1,19 @@
{ {lib, ...}: let
inherit (lib.modules) mkRemovedOptionModule;
in {
imports = [ imports = [
(mkRemovedOptionModule ["vim" "visuals" "enable"] ''
As top-level toggles are being deprecated, you are encouraged
to handle plugin toggles under individual options.
'')
./cellular-automaton ./cellular-automaton
./cinnamon-nvim ./cinnamon-nvim
./fidget-nvim ./fidget-nvim
./highlight-undo
./indent-blankline ./indent-blankline
./nvim-cursorline ./nvim-cursorline
./nvim-scrollbar ./nvim-scrollbar
./nvim-web-devicons ./nvim-web-devicons
./config.nix
./visuals.nix
]; ];
} }

View file

@ -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})
'';
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./highlight-undo.nix
];
}

View file

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

View file

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