Merge pull request #825 from horriblename/fix-additional-rtp-override

rc: do not set options via luaConfigPre
This commit is contained in:
raf 2025-04-21 06:59:01 +00:00 committed by GitHub
commit d2cb38ca0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 25 deletions

View file

@ -107,6 +107,8 @@
- Add `LazyFile` user event. - Add `LazyFile` user event.
- Migrate language modules from none-ls to conform/nvim-lint - Migrate language modules from none-ls to conform/nvim-lint
- Add tsx support in conform and lint - Add tsx support in conform and lint
- Moved code setting `additionalRuntimePaths` and `enableLuaLoader` out of
`luaConfigPre`'s default to prevent being overridden
[diniamo](https://github.com/diniamo): [diniamo](https://github.com/diniamo):

View file

@ -5,7 +5,7 @@
}: let }: let
inherit (builtins) map mapAttrs filter; inherit (builtins) map mapAttrs filter;
inherit (lib.attrsets) mapAttrsToList; inherit (lib.attrsets) mapAttrsToList;
inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.strings) concatLines concatMapStringsSep optionalString;
inherit (lib.trivial) showWarnings; inherit (lib.trivial) showWarnings;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere; inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
@ -72,6 +72,14 @@ in {
dag = cfg.luaConfigRC; dag = cfg.luaConfigRC;
mapResult = result: mapResult = result:
concatLines [ concatLines [
(optionalString (cfg.additionalRuntimePaths != []) ''
vim.opt.runtimepath:append(${toLuaObject cfg.additionalRuntimePaths})
'')
(optionalString cfg.enableLuaLoader ''
if vim.loader then
vim.loader.enable()
end
'')
cfg.luaConfigPre cfg.luaConfigPre
(concatMapStringsSep "\n" mkLuarcSection result) (concatMapStringsSep "\n" mkLuarcSection result)
cfg.luaConfigPost cfg.luaConfigPost

View file

@ -1,15 +1,7 @@
{ {lib, ...}: let
config,
lib,
...
}: let
inherit (lib.options) mkOption literalMD literalExpression; 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;
inherit (lib.nvim.types) dagOf; inherit (lib.nvim.types) dagOf;
inherit (lib.nvim.lua) listToLuaTable;
cfg = config.vim;
in { in {
options.vim = { options.vim = {
enableLuaLoader = mkOption { enableLuaLoader = mkOption {
@ -286,21 +278,7 @@ in {
luaConfigPre = mkOption { luaConfigPre = mkOption {
type = str; type = str;
default = '' 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
''}
'';
defaultText = literalMD '' defaultText = literalMD ''
By default, this option will **append** paths in By default, this option will **append** paths in
[](#opt-vim.additionalRuntimePaths) [](#opt-vim.additionalRuntimePaths)