treewide: migrate to pluginRC for correct DAG order

The "new" DAG order is as follows:
- (luaConfigPre)
- globalsScript
- basic
- theme
- pluginConfigs
- extraPluginConfigs
- mappings
- (luaConfigPost)
This commit is contained in:
diniamo 2024-07-15 12:40:05 +02:00
commit a0197fe1bb
67 changed files with 101 additions and 87 deletions

View file

@ -86,6 +86,18 @@ in {
mapAttrsFlatten (name: value: "vim.g.${name} = ${toLuaObject value}")
(filterNonNull cfg.globals);
extraPluginConfigs = resolveDag {
name = "extra plugin configs";
dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins;
mapResult = result: concatLines (map mkLuarcSection result);
};
pluginConfigs = resolveDag {
name = "plugin configs";
dag = cfg.pluginRC;
mapResult = result: concatLines (map mkLuarcSection result);
};
toLuaBindings = mode: maps:
map (value: ''
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
@ -104,12 +116,6 @@ in {
omap = toLuaBindings "o" config.vim.maps.operator;
icmap = toLuaBindings "ic" config.vim.maps.insertCommand;
extraPluginConfigs = resolveDag {
name = "extra plugins config";
dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins;
mapResult = result: concatLines (map mkLuarcSection result);
};
maps = [
nmap
imap
@ -128,6 +134,11 @@ in {
vim = {
luaConfigRC = {
globalsScript = concatLines globalsScript;
# basic comes after globalsScript,
# but it's defined modules/neovim/init/basic.nix
pluginConfigs = entryAfter ["basic"] pluginConfigs;
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
mappings = entryAfter ["extraPluginConfigs"] mappings;
};
builtLuaConfigRC = let
@ -145,11 +156,7 @@ in {
mapResult = result:
concatLines [
cfg.luaConfigPre
(concatMapStringsSep "\n" mkLuarcSection result)
extraPluginConfigs
mappings
cfg.luaConfigPost
];
};

View file

@ -5,7 +5,7 @@
}: let
inherit (lib.options) mkOption mkEnableOption literalMD literalExpression;
inherit (lib.strings) optionalString;
inherit (lib.types) str oneOf attrs lines listOf either path bool;
inherit (lib.types) str attrs lines listOf either path bool;
inherit (lib.nvim.types) dagOf;
inherit (lib.nvim.lua) listToLuaTable;
cfg = config.vim;
@ -130,6 +130,13 @@ in {
'';
};
pluginRC = mkOption {
internal = true;
type = either (dagOf lines) str;
default = {};
description = "The internal DAG used to configure plugins";
};
luaConfigPre = mkOption {
type = str;
default = ''
@ -190,7 +197,7 @@ in {
};
luaConfigRC = mkOption {
type = oneOf [(dagOf lines) str];
type = either (dagOf lines) str;
default = {};
description = ''
Lua configuration, either as a string or a DAG.