mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 13:20:44 +00:00
lib: switch to mkLuaInline
This commit is contained in:
parent
5ea6272bee
commit
77d3cd5e0c
3 changed files with 9 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue