2022-09-18 11:19:23 +01:00
|
|
|
{
|
2023-02-20 11:42:13 +01:00
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
|
|
|
}:
|
2023-12-28 11:14:57 +01:00
|
|
|
let
|
|
|
|
optionsAttrs = {
|
2024-03-29 20:58:44 +00:00
|
|
|
opts = {
|
2023-12-28 11:14:57 +01:00
|
|
|
prettyName = "options";
|
|
|
|
luaVariableName = "options";
|
|
|
|
luaApi = "opt";
|
2023-12-29 10:30:47 +01:00
|
|
|
description = "The configuration options, e.g. line numbers (`vim.opt.*`)";
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
2024-03-29 20:58:44 +00:00
|
|
|
globalOpts = {
|
2023-12-28 11:14:57 +01:00
|
|
|
prettyName = "global options";
|
|
|
|
luaVariableName = "global_options";
|
|
|
|
luaApi = "opt_global";
|
2023-12-29 10:30:47 +01:00
|
|
|
description = "The configuration global options (`vim.opt_global.*`)";
|
2023-12-27 17:02:05 +01:00
|
|
|
};
|
|
|
|
|
2024-03-29 20:58:44 +00:00
|
|
|
localOpts = {
|
2023-12-28 11:14:57 +01:00
|
|
|
prettyName = "local options";
|
|
|
|
luaVariableName = "local_options";
|
|
|
|
luaApi = "opt_local";
|
2023-12-29 10:30:47 +01:00
|
|
|
description = "The configuration local options (`vim.opt_local.*`)";
|
2023-12-27 17:02:05 +01:00
|
|
|
};
|
|
|
|
|
2023-12-28 11:14:57 +01:00
|
|
|
globals = {
|
|
|
|
prettyName = "globals";
|
|
|
|
luaVariableName = "globals";
|
|
|
|
luaApi = "g";
|
2023-12-29 10:30:47 +01:00
|
|
|
description = "Global variables (`vim.g.*`)";
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
};
|
2023-12-28 11:14:57 +01:00
|
|
|
in
|
|
|
|
{
|
2024-08-30 14:37:41 -05:00
|
|
|
options = lib.mapAttrs (
|
2023-12-28 11:14:57 +01:00
|
|
|
_:
|
|
|
|
{ description, ... }:
|
2024-08-30 14:37:41 -05:00
|
|
|
lib.mkOption {
|
|
|
|
type = with lib.types; attrsOf anything;
|
2023-12-28 11:14:57 +01:00
|
|
|
default = { };
|
|
|
|
inherit description;
|
|
|
|
}
|
|
|
|
) optionsAttrs;
|
2022-09-18 11:19:23 +01:00
|
|
|
|
2024-03-29 20:58:44 +00:00
|
|
|
# Added 2024-03-29 (do not remove)
|
2024-08-30 14:37:41 -05:00
|
|
|
imports = lib.mapAttrsToList (old: new: lib.mkRenamedOptionModule [ old ] [ new ]) {
|
2024-03-29 20:58:44 +00:00
|
|
|
options = "opts";
|
|
|
|
globalOptions = "globalOpts";
|
|
|
|
localOptions = "localOpts";
|
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
config = {
|
2024-07-21 20:59:16 +03:00
|
|
|
extraConfigLuaPre =
|
|
|
|
let
|
|
|
|
content = helpers.concatNonEmptyLines (
|
2024-08-30 14:37:41 -05:00
|
|
|
lib.mapAttrsToList (
|
2024-07-21 20:59:16 +03:00
|
|
|
optionName:
|
|
|
|
{
|
|
|
|
prettyName,
|
|
|
|
luaVariableName,
|
|
|
|
luaApi,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
varName = "nixvim_${luaVariableName}";
|
2024-12-15 20:32:14 +01:00
|
|
|
optionDefinitions = lib.nixvim.toLuaObject config.${optionName};
|
2024-07-21 20:59:16 +03:00
|
|
|
in
|
2024-11-20 16:24:36 +01:00
|
|
|
lib.optionalString (optionDefinitions != "{ }") ''
|
2024-07-21 20:59:16 +03:00
|
|
|
-- Set up ${prettyName} {{{
|
|
|
|
do
|
2024-11-20 16:24:36 +01:00
|
|
|
local ${varName} = ${optionDefinitions}
|
2022-09-18 11:19:23 +01:00
|
|
|
|
2024-07-21 20:59:16 +03:00
|
|
|
for k,v in pairs(${varName}) do
|
|
|
|
vim.${luaApi}[k] = v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
''
|
|
|
|
) optionsAttrs
|
|
|
|
);
|
|
|
|
in
|
2024-08-30 14:37:41 -05:00
|
|
|
lib.mkIf (content != "") (lib.mkOrder 600 content); # Move options to top of file below global table
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
}
|