mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-08 06:55:58 +01:00
visuals: move highlight-undo to its own module; deprecate old opts
Upstream cucked us.
This commit is contained in:
parent
dad69f8af9
commit
901038145d
6 changed files with 68 additions and 100 deletions
|
@ -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 = {}
|
||||
},
|
||||
})
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -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
|
||||
];
|
||||
}
|
||||
|
|
21
modules/plugins/visuals/highlight-undo/config.nix
Normal file
21
modules/plugins/visuals/highlight-undo/config.nix
Normal 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})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/visuals/highlight-undo/default.nix
Normal file
6
modules/plugins/visuals/highlight-undo/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./highlight-undo.nix
|
||||
];
|
||||
}
|
32
modules/plugins/visuals/highlight-undo/highlight-undo.nix
Normal file
32
modules/plugins/visuals/highlight-undo/highlight-undo.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue