mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-02 09:04:54 +02:00
Rename options
to avoid confusion with module options (#1324)
This commit is contained in:
parent
acb917fbf2
commit
4f83bcf290
18 changed files with 33 additions and 43 deletions
92
modules/opts.nix
Normal file
92
modules/opts.nix
Normal file
|
@ -0,0 +1,92 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
optionsAttrs = {
|
||||
opts = {
|
||||
prettyName = "options";
|
||||
luaVariableName = "options";
|
||||
luaApi = "opt";
|
||||
description = "The configuration options, e.g. line numbers (`vim.opt.*`)";
|
||||
};
|
||||
|
||||
globalOpts = {
|
||||
prettyName = "global options";
|
||||
luaVariableName = "global_options";
|
||||
luaApi = "opt_global";
|
||||
description = "The configuration global options (`vim.opt_global.*`)";
|
||||
};
|
||||
|
||||
localOpts = {
|
||||
prettyName = "local options";
|
||||
luaVariableName = "local_options";
|
||||
luaApi = "opt_local";
|
||||
description = "The configuration local options (`vim.opt_local.*`)";
|
||||
};
|
||||
|
||||
globals = {
|
||||
prettyName = "globals";
|
||||
luaVariableName = "globals";
|
||||
luaApi = "g";
|
||||
description = "Global variables (`vim.g.*`)";
|
||||
};
|
||||
};
|
||||
in {
|
||||
options =
|
||||
mapAttrs
|
||||
(
|
||||
_: {description, ...}:
|
||||
mkOption {
|
||||
type = with types; attrsOf anything;
|
||||
default = {};
|
||||
inherit description;
|
||||
}
|
||||
)
|
||||
optionsAttrs;
|
||||
|
||||
# Added 2024-03-29 (do not remove)
|
||||
imports =
|
||||
mapAttrsToList
|
||||
(old: new: mkRenamedOptionModule [old] [new])
|
||||
{
|
||||
options = "opts";
|
||||
globalOptions = "globalOpts";
|
||||
localOptions = "localOpts";
|
||||
};
|
||||
|
||||
config = {
|
||||
extraConfigLuaPre =
|
||||
concatLines
|
||||
(
|
||||
mapAttrsToList
|
||||
(
|
||||
optionName: {
|
||||
prettyName,
|
||||
luaVariableName,
|
||||
luaApi,
|
||||
...
|
||||
}: let
|
||||
varName = "nixvim_${luaVariableName}";
|
||||
optionDefinitions = config.${optionName};
|
||||
in
|
||||
optionalString
|
||||
(optionDefinitions != {})
|
||||
''
|
||||
-- Set up ${prettyName} {{{
|
||||
do
|
||||
local ${varName} = ${helpers.toLuaObject optionDefinitions}
|
||||
|
||||
for k,v in pairs(${varName}) do
|
||||
vim.${luaApi}[k] = v
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
''
|
||||
)
|
||||
optionsAttrs
|
||||
);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue