mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-02 21:34:33 +02:00
startify: init plugin
This commit is contained in:
parent
43ce0d77db
commit
3624689305
6 changed files with 265 additions and 3 deletions
|
@ -53,9 +53,48 @@ rec {
|
|||
}) normalized);
|
||||
|
||||
# Creates an option with a nullable type that defaults to null.
|
||||
nullOrOption = type: desc: lib.mkOption {
|
||||
mkNullOrOption = type: desc: lib.mkOption {
|
||||
type = lib.types.nullOr type;
|
||||
default = null;
|
||||
description = desc;
|
||||
};
|
||||
|
||||
mkPlugin = { config, lib, ... }: {
|
||||
name,
|
||||
description,
|
||||
extraPlugins ? [],
|
||||
options ? {},
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.nixvim.plugins.${name};
|
||||
# TODO support nested options!
|
||||
pluginOptions = mapAttrs (k: v: v.option) options;
|
||||
globals = mapAttrs' (name: opt: {
|
||||
name = opt.global;
|
||||
value = if cfg.${name} != null then opt.value cfg.${name} else null;
|
||||
}) options;
|
||||
in {
|
||||
options.programs.nixvim.plugins.${name} = {
|
||||
enable = mkEnableOption description;
|
||||
} // pluginOptions;
|
||||
|
||||
config.programs.nixvim = mkIf cfg.enable {
|
||||
inherit extraPlugins globals;
|
||||
};
|
||||
};
|
||||
|
||||
globalVal = val: if builtins.isBool val then
|
||||
(if val == false then 0 else 1)
|
||||
else val;
|
||||
|
||||
mkDefaultOpt = { type, global, description ? null, example ? null, value ? v: toLuaObject (globalVal v), ... }: {
|
||||
option = mkOption {
|
||||
type = types.nullOr type;
|
||||
default = null;
|
||||
description = description;
|
||||
example = example;
|
||||
};
|
||||
|
||||
inherit value global;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue