mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-13 16:18:36 +00:00
rc: bindings to vim.opt
This commit is contained in:
parent
ae3fd99447
commit
22d08b431a
2 changed files with 55 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.strings) concatLines concatMapStringsSep;
|
||||
inherit (lib.trivial) showWarnings;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
@ -18,7 +19,19 @@ in {
|
|||
mapAttrsToList (name: value: "vim.g.${name} = ${toLuaObject value}") cfg.globals;
|
||||
|
||||
optionsScript =
|
||||
mapAttrsToList (name: value: "vim.o.${name} = ${toLuaObject value}") cfg.options;
|
||||
mapAttrsToList (name: value: "vim.o.${name} = ${toLuaObject value}") cfg.options
|
||||
++ mapAttrsToList (
|
||||
name: {
|
||||
append,
|
||||
prepend,
|
||||
remove,
|
||||
}:
|
||||
concatLines
|
||||
((optional (append != null) "vim.opt.${name}:append(${toLuaObject append})")
|
||||
++ (optional (prepend != null) "vim.opt.${name}:prepend(${toLuaObject prepend})")
|
||||
++ (optional (remove != null) "vim.opt.${name}:remove(${toLuaObject remove})"))
|
||||
)
|
||||
cfg.opt;
|
||||
|
||||
extraPluginConfigs = resolveDag {
|
||||
name = "extra plugin configs";
|
||||
|
|
|
@ -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 = {};
|
||||
|
|
Loading…
Add table
Reference in a new issue