{ lib, pkgs, ... }: let inherit (lib.nix2lua) require var local set pipe1 call; pluginOpts = ({ name, config, ... }: { options = with lib; with types; { enable = mkEnableOption "Enable plugin " // { default = true; }; name = mkOption { type = str; }; extraImports = mkOption { type = attrsOf (either str attrs); default = { }; example = { hint = "hop.hint"; }; }; varName = mkOption { type = nullOr str; default = null; }; var = mkOption { type = attrs; internal = true; }; package = mkPackageOption pkgs.vimPlugins name { }; beforeSetup = mkOption { type = listOf attrs; default = [ ]; }; setupFnName = mkOption { type = str; default = "setup"; }; setupSettings = mkOption { type = nullOr (either attrs (listOf anything)); default = null; }; afterSetup = mkOption { type = listOf attrs; default = [ ]; }; extra = mkOption { type = listOf attrs; default = [ ]; }; genConfig = mkOption { type = listOf attrs; readOnly = true; internal = true; }; luaConfig = mkOption { type = str; readOnly = true; internal = true; }; }; config = { name = lib.mkDefault name; var = if config.varName != null then var config.varName else require config.name; genConfig = with lib; mkIf config.enable (flatten [ (lib.optional (config.varName != null) (local (set config.varName (require config.name)))) (mapAttrsToList (k: v: local (set k (if builtins.isString v then require v else v))) config.extraImports ) config.beforeSetup (optional (config.setupSettings != null) (pipe1 config.var (call config.setupFnName config.setupSettings) ) ) config.afterSetup config.extra ]); luaConfig = with lib.nix2lua; toLua (spaceBetween config.genConfig); }; }); in { options.plugin = with lib; mkOption { type = with types; attrsOf (submodule pluginOpts); default = { }; }; }