rc: bindings to vim.opt

This commit is contained in:
Ching Pei Yang 2025-02-25 14:32:30 +01:00
commit 22d08b431a
No known key found for this signature in database
GPG key ID: B3841364253DC4C8
2 changed files with 55 additions and 2 deletions

View file

@ -5,7 +5,7 @@
}: let
inherit (lib.options) mkOption literalMD literalExpression;
inherit (lib.strings) optionalString;
inherit (lib.types) str bool int enum attrsOf lines listOf either path submodule anything;
inherit (lib.types) str bool int enum attrsOf lines listOf either path submodule anything nullOr;
inherit (lib.nvim.types) dagOf;
inherit (lib.nvim.lua) listToLuaTable;
@ -278,6 +278,46 @@ in {
'';
};
opt = mkOption {
default = {};
type = attrsOf (submodule {
options = {
append = mkOption {
type = nullOr (listOf anything);
default = null;
description = "Values to append";
};
prepend = mkOption {
type = nullOr (listOf anything);
default = null;
description = "Values to prepend";
};
remove = mkOption {
type = nullOr (listOf anything);
default = null;
description = "Values to remove";
};
};
});
example = literalExpression ''
{
runtimepath.append = ["~/.config/nvim"];
formatoptions.append = ["n"];
formatoptions.remove = ["o"];
}
'';
description = ''
Wrapper of the lua `vim.opt` interface. Makes interacting with list and
map-style option more convenient.
If you're looking to set an option normally, instead of add/remove from
a list/map type option, see {option}`vim.options` instead.
'';
};
pluginRC = mkOption {
type = either (dagOf lines) str;
default = {};