From 77d3cd5e0c05bac3eacc6b9ebdb3ee478c393f69 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 16 Mar 2024 09:29:07 +0000 Subject: [PATCH] lib: switch to mkLuaInline --- lib/lua.nix | 6 ++++-- lib/types/default.nix | 2 +- lib/types/plugins.nix | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index d7dd982..eded8f3 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -48,11 +48,13 @@ in rec { # Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first luaTable = items: ''{${concatStringsSep "," items}}''; + isLuaInline = {_type ? null, ...}: _type == "lua-inline"; + toLuaObject = args: if isAttrs args then - if hasAttr "__raw" args - then args.__raw + if isLuaInline args + then args.expr else if hasAttr "__empty" args then "{ }" else diff --git a/lib/types/default.nix b/lib/types/default.nix index 22b728d..89ce1ba 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -4,6 +4,6 @@ typesLanguage = import ./languages.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption rawLua; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline; inherit (typesLanguage) diagnostics mkGrammarOption; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 813108f..e8db87a 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -145,13 +145,13 @@ in { type = pluginsType; }; - rawLua = lib.mkOptionType { - name = "rawLua"; - check = val: isString val || val ? __raw; + luaInline = lib.mkOptionType { + name = "luaInline"; + check = x: lib.nvim.lua.isLuaInline x || builtins.isString x; merge = loc: defs: let val = if isString loc - then {__raw = val;} + then lib.generators.mkLuaInline loc else loc; in lib.mergeOneOption val defs;