nixvim/plugins/nvim-config-local: update to RFC-45-style settings

This commit is contained in:
Gabriel Arazas 2024-08-15 12:49:44 +08:00
parent 54c66be82f
commit 23230295a4
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360

View File

@ -4,40 +4,34 @@ let
cfg = config.plugins.nvim-config-local; cfg = config.plugins.nvim-config-local;
in in
{ {
options.plugins.nvim-config-local = options.plugins.nvim-config-local = {
helpers.neovim-plugin.extraOptionsOptions // { enable = lib.mkEnableOption "nvim-config-local";
enable = lib.mkEnableOption "nvim-config-local";
package = helpers.mkPluginPackageOption "nvim-config-local" pkgs.vimPlugins.nvim-config-local; package = helpers.mkPluginPackageOption "nvim-config-local" pkgs.vimPlugins.nvim-config-local;
configFiles = lib.mkOption { settings = lib.mkOption {
type = with lib.types; listOf str; type = lib.types.submodule {
default = [ ".nvim.lua" ".nvimrc" ".exrc" ]; freeformType = with lib.types; attrsOf anything;
example = [ "config/nvim.lua" ]; options = {
description = '' config_files = lib.mkOption {
A list of patterns to load (includes Lua configurations). type = with lib.types; listOf str;
''; default = [ ".nvim.lua" ".nvimrc" ".exrc" ];
example = [ "config/nvim.lua" ];
description = ''
A list of patterns to load (includes Lua configurations).
'';
};
};
}; };
autocommandsCreate = helpers.defaultNullOpts.mkBool true "Create autocommands for sourcing local files.";
commandsCreate = helpers.defaultNullOpts.mkBool true "Create user commands for nvim-config-local.";
lookupParents = helpers.defaultNullOpts.mkBool false "Enable lookup in parent directories when sourcing local configs.";
}; };
};
config = config =
let
setupOptions = {
config_files = cfg.configFiles;
autocommands_create = cfg.autocommandsCreate;
commands_create = cfg.commandsCreate;
lookup_parents = cfg.lookupParents;
} // cfg.extraOptions;
in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [ cfg.package ];
extraConfigLua = '' extraConfigLua = ''
require("config-local").setup(${helpers.toLuaConfig setupOptions}) require("config-local").setup(${helpers.toLuaConfig cfg.settings})
''; '';
}; };
} }