From db3a35a116d93162d9bc07264ede37404b243f0a Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 13 Apr 2025 11:14:50 +0200 Subject: [PATCH] rc: do not set options via luaConfigPre --- modules/wrapper/rc/config.nix | 10 +++++++++- modules/wrapper/rc/options.nix | 26 ++------------------------ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index ff8a4585..77a62d58 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -5,7 +5,7 @@ }: let inherit (builtins) map mapAttrs filter; inherit (lib.attrsets) mapAttrsToList; - inherit (lib.strings) concatLines concatMapStringsSep; + inherit (lib.strings) concatLines concatMapStringsSep optionalString; inherit (lib.trivial) showWarnings; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere; @@ -72,6 +72,14 @@ in { dag = cfg.luaConfigRC; mapResult = result: concatLines [ + (optionalString (cfg.additionalRuntimePaths != []) '' + vim.opt.runtimepath:append(${toLuaObject cfg.additionalRuntimePaths}) + '') + (optionalString cfg.enableLuaLoader '' + if vim.loader then + vim.loader.enable() + end + '') cfg.luaConfigPre (concatMapStringsSep "\n" mkLuarcSection result) cfg.luaConfigPost diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 4cd3026f..10abd77d 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -1,15 +1,7 @@ -{ - config, - lib, - ... -}: let +{lib, ...}: 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.nvim.types) dagOf; - inherit (lib.nvim.lua) listToLuaTable; - - cfg = config.vim; in { options.vim = { enableLuaLoader = mkOption { @@ -286,21 +278,7 @@ in { luaConfigPre = mkOption { type = str; - default = '' - ${optionalString (cfg.additionalRuntimePaths != []) '' - -- The following list is generated from `vim.additionalRuntimePaths` - -- and is used to append additional runtime paths to the - -- `runtimepath` option. - vim.opt.runtimepath:append(${listToLuaTable cfg.additionalRuntimePaths}) - ''} - - ${optionalString cfg.enableLuaLoader '' - if vim.loader then - vim.loader.enable() - end - ''} - ''; - + default = ""; defaultText = literalMD '' By default, this option will **append** paths in [](#opt-vim.additionalRuntimePaths)