mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-28 03:20:08 +02:00
plugins/mark-radar: refactor + tests (#287)
This commit is contained in:
parent
cbae935d89
commit
5ae654b74d
2 changed files with 69 additions and 29 deletions
|
@ -3,50 +3,73 @@
|
|||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
} @ args:
|
||||
with lib; let
|
||||
cfg = config.plugins.mark-radar;
|
||||
helpers = import ../helpers.nix {inherit lib;};
|
||||
defs = import ../plugin-defs.nix {inherit pkgs;};
|
||||
optionWarnings = import ../../lib/option-warnings.nix args;
|
||||
basePluginPath = ["plugins" "mark-radar"];
|
||||
in {
|
||||
options.plugins.mark-radar = {
|
||||
# Those renames were done on 03-24-2023
|
||||
imports = [
|
||||
(optionWarnings.mkRenamedOption {
|
||||
option = basePluginPath ++ ["highlight_background"];
|
||||
newOption = basePluginPath ++ ["backgroundHighlight"];
|
||||
})
|
||||
(optionWarnings.mkRenamedOption {
|
||||
option = basePluginPath ++ ["background_highlight_group"];
|
||||
newOption = basePluginPath ++ ["backgroundHighlightGroup"];
|
||||
})
|
||||
(optionWarnings.mkRenamedOption {
|
||||
option = basePluginPath ++ ["highlight_group"];
|
||||
newOption = basePluginPath ++ ["highlightGroup"];
|
||||
})
|
||||
(optionWarnings.mkRenamedOption {
|
||||
option = basePluginPath ++ ["set_default_keybinds"];
|
||||
newOption = basePluginPath ++ ["setDefaultMappings"];
|
||||
})
|
||||
];
|
||||
|
||||
options.plugins.mark-radar =
|
||||
helpers.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "mark-radar";
|
||||
|
||||
package = helpers.mkPackageOption "mark-radar" defs.mark-radar;
|
||||
|
||||
highlight_background = mkOption {
|
||||
type = with types; nullOr bool;
|
||||
default = null;
|
||||
};
|
||||
setDefaultMappings =
|
||||
helpers.defaultNullOpts.mkBool true
|
||||
"Whether to set default mappings.";
|
||||
|
||||
background_highlight_group = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
highlightGroup =
|
||||
helpers.defaultNullOpts.mkStr "RadarMark"
|
||||
"The name of the highlight group to use.";
|
||||
|
||||
highlight_group = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
backgroundHighlight =
|
||||
helpers.defaultNullOpts.mkBool true
|
||||
"Whether to highlight the background.";
|
||||
|
||||
set_default_keybinds = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
backgroundHighlightGroup =
|
||||
helpers.defaultNullOpts.mkStr "RadarBackground"
|
||||
"The name of the highlight group to use for the background.";
|
||||
};
|
||||
|
||||
config = let
|
||||
opts = helpers.toLuaObject {
|
||||
inherit (cfg) highlight_group background_highlight_group;
|
||||
set_default_mappings = cfg.set_default_keybinds;
|
||||
background_highlight = cfg.highlight_background;
|
||||
};
|
||||
setupOptions =
|
||||
{
|
||||
set_default_mappings = cfg.setDefaultMappings;
|
||||
highlight_group = cfg.highlightGroup;
|
||||
background_highlight = cfg.backgroundHighlight;
|
||||
background_highlight_group = cfg.backgroundHighlightGroup;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
extraConfigLua = ''
|
||||
require("mark-radar").setup(${opts})
|
||||
require("mark-radar").setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
17
tests/test-sources/plugins/utils/mark-radar.nix
Normal file
17
tests/test-sources/plugins/utils/mark-radar.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.mark-radar.enable = true;
|
||||
};
|
||||
|
||||
# All the upstream default options of mark-radar
|
||||
defaults = {
|
||||
plugins.mark-radar = {
|
||||
enable = true;
|
||||
|
||||
setDefaultMappings = true;
|
||||
highlightGroup = "RadarMark";
|
||||
backgroundHighlight = true;
|
||||
backgroundHighlightGroup = "RadarBackground";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue