wrapper/rc: add vim.options

Translates an attribute set of values into `vim.o` values in a key-value format.
This commit is contained in:
raf 2024-09-28 19:47:20 +03:00
commit 5d8fc297b6
Signed by: NotAShelf
GPG key ID: AF26552424E53993
2 changed files with 31 additions and 4 deletions

View file

@ -85,6 +85,10 @@ in {
mapAttrsToList (name: value: "vim.g.${name} = ${toLuaObject value}") mapAttrsToList (name: value: "vim.g.${name} = ${toLuaObject value}")
(filterNonNull cfg.globals); (filterNonNull cfg.globals);
optionsScript =
mapAttrsToList (name: value: "vim.o.${name} = ${toLuaObject value}")
(filterNonNull cfg.options);
extraPluginConfigs = resolveDag { extraPluginConfigs = resolveDag {
name = "extra plugin configs"; name = "extra plugin configs";
dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins; dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins;
@ -132,9 +136,12 @@ in {
in { in {
vim = { vim = {
luaConfigRC = { luaConfigRC = {
# `vim.g` and `vim.o`
globalsScript = entryAnywhere (concatLines globalsScript); globalsScript = entryAnywhere (concatLines globalsScript);
# basic optionsScript = entryAfter ["basic"] (concatLines optionsScript);
pluginConfigs = entryAfter ["basic"] pluginConfigs;
# Basic
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs; extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
mappings = entryAfter ["extraPluginConfigs"] mappings; mappings = entryAfter ["extraPluginConfigs"] mappings;
}; };

View file

@ -135,10 +135,30 @@ in {
populated, this option will set vim variables in the populated, this option will set vim variables in the
built luaConfigRC as the first item. built luaConfigRC as the first item.
E.g. {foo = "bar"} will set `vim.g.foo` to "bar" where ::: {.note}
the type of `bar` in the resulting vimscript will be `{foo = "bar";}` will set `vim.g.foo` to "bar" where
the type of `bar` in the resulting Lua value will be
infered from the type of the value in the `{name = value;}`
pair.
:::
'';
};
options = mkOption {
type = attrs;
default = {};
description = ''
An attribute set containing vim options to be set
as early as possible. If populated, this option will
set vim options in the built luaConfigRC after `basic`
and before `pluginConfigs` DAG entries.
::: {.note}
`{foo = "bar"}` will set `vim.o.foo` to "bar" where
the type of `bar` in the resulting Lua value will be
infered from the type of the value in the `{name = value}` infered from the type of the value in the `{name = value}`
pair. pair.
:::
''; '';
}; };