mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 00:48:58 +02:00
plugins/floaterm: refactor + keymap options (#189)
This commit is contained in:
parent
c9cbf5172a
commit
714a094ff5
1 changed files with 229 additions and 173 deletions
|
@ -1,45 +1,16 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
} @ args:
|
} @ args:
|
||||||
with lib;
|
with lib; let
|
||||||
with import ../helpers.nix {inherit lib;};
|
cfg = config.plugins.floaterm;
|
||||||
{
|
helpers = import ../helpers.nix {inherit lib;};
|
||||||
imports = let
|
|
||||||
optionWarnings = import ../../lib/option-warnings.nix args;
|
optionWarnings = import ../../lib/option-warnings.nix args;
|
||||||
basePluginPath = ["plugins" "floaterm"];
|
basePluginPath = ["plugins" "floaterm"];
|
||||||
in [
|
|
||||||
(optionWarnings.mkRenamedOption {
|
|
||||||
option = basePluginPath ++ ["winType"];
|
|
||||||
newOption = basePluginPath ++ ["wintype"];
|
|
||||||
})
|
|
||||||
(optionWarnings.mkRenamedOption {
|
|
||||||
option = basePluginPath ++ ["winWidth"];
|
|
||||||
newOption = basePluginPath ++ ["width"];
|
|
||||||
})
|
|
||||||
(optionWarnings.mkRenamedOption {
|
|
||||||
option = basePluginPath ++ ["winHeight"];
|
|
||||||
newOption = basePluginPath ++ ["height"];
|
|
||||||
})
|
|
||||||
(optionWarnings.mkRenamedOption {
|
|
||||||
option = basePluginPath ++ ["borderChars"];
|
|
||||||
newOption = basePluginPath ++ ["borderchars"];
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
|
||||||
// mkPlugin args {
|
|
||||||
name = "floaterm";
|
|
||||||
description = "floaterm";
|
|
||||||
package = pkgs.vimPlugins.vim-floaterm;
|
|
||||||
|
|
||||||
options =
|
settings = {
|
||||||
mapAttrs (name: value:
|
|
||||||
mkDefaultOpt {
|
|
||||||
global = "floaterm_${name}";
|
|
||||||
inherit (value) type description;
|
|
||||||
})
|
|
||||||
{
|
|
||||||
shell = {
|
shell = {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "";
|
description = "";
|
||||||
|
@ -178,4 +149,89 @@ with import ../helpers.nix {inherit lib;};
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
in {
|
||||||
|
imports = [
|
||||||
|
(optionWarnings.mkRenamedOption {
|
||||||
|
option = basePluginPath ++ ["winType"];
|
||||||
|
newOption = basePluginPath ++ ["wintype"];
|
||||||
|
})
|
||||||
|
(optionWarnings.mkRenamedOption {
|
||||||
|
option = basePluginPath ++ ["winWidth"];
|
||||||
|
newOption = basePluginPath ++ ["width"];
|
||||||
|
})
|
||||||
|
(optionWarnings.mkRenamedOption {
|
||||||
|
option = basePluginPath ++ ["winHeight"];
|
||||||
|
newOption = basePluginPath ++ ["height"];
|
||||||
|
})
|
||||||
|
(optionWarnings.mkRenamedOption {
|
||||||
|
option = basePluginPath ++ ["borderChars"];
|
||||||
|
newOption = basePluginPath ++ ["borderchars"];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
options.plugins.floaterm = let
|
||||||
|
# Misc options
|
||||||
|
# `OPTION = VALUE`
|
||||||
|
# which will translate to `globals.floaterm_OPTION = VALUE;`
|
||||||
|
miscOptions =
|
||||||
|
mapAttrs
|
||||||
|
(name: value: helpers.mkNullOrOption value.type value.description)
|
||||||
|
settings;
|
||||||
|
|
||||||
|
# Keymaps options
|
||||||
|
# `keymaps.ACTION = KEY`
|
||||||
|
# which will translate to `globals.floaterm_keymap_ACTION = KEY;`
|
||||||
|
keymapOptions = listToAttrs (
|
||||||
|
map (
|
||||||
|
name: {
|
||||||
|
inherit name;
|
||||||
|
value = helpers.mkNullOrOption types.str "Key to map to ${name}";
|
||||||
}
|
}
|
||||||
|
) [
|
||||||
|
"new"
|
||||||
|
"prev"
|
||||||
|
"next"
|
||||||
|
"first"
|
||||||
|
"last"
|
||||||
|
"hide"
|
||||||
|
"show"
|
||||||
|
"kill"
|
||||||
|
"toggle"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
enable = mkEnableOption "floaterm";
|
||||||
|
|
||||||
|
package = helpers.mkPackageOption "floaterm" pkgs.vimPlugins.vim-floaterm;
|
||||||
|
|
||||||
|
keymaps = keymapOptions;
|
||||||
|
}
|
||||||
|
// miscOptions;
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
extraPlugins = [cfg.package];
|
||||||
|
|
||||||
|
globals = let
|
||||||
|
# misc options
|
||||||
|
optionGlobals = listToAttrs (
|
||||||
|
map
|
||||||
|
(optionName: {
|
||||||
|
name = "floaterm_${optionName}";
|
||||||
|
value = cfg.${optionName};
|
||||||
|
})
|
||||||
|
(attrNames settings)
|
||||||
|
);
|
||||||
|
|
||||||
|
# keymaps options
|
||||||
|
keymapGlobals =
|
||||||
|
mapAttrs'
|
||||||
|
(name: key: {
|
||||||
|
name = "floaterm_keymap_${name}";
|
||||||
|
value = key;
|
||||||
|
})
|
||||||
|
cfg.keymaps;
|
||||||
|
in
|
||||||
|
optionGlobals // keymapGlobals;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue