mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 17:15:58 +01:00
32 lines
689 B
Nix
32 lines
689 B
Nix
# Helpers for converting values to lua
|
|
{lib}: rec {
|
|
# yes? no.
|
|
yesNo = value:
|
|
if value
|
|
then "yes"
|
|
else "no";
|
|
|
|
# Convert a null value to lua's nil
|
|
nullString = value:
|
|
if value == null
|
|
then "nil"
|
|
else "'${value}'";
|
|
|
|
# Helper function to convert an attribute name to a Lua table key
|
|
attrToKey = name: name;
|
|
|
|
# Function to convert a Nix attrset to a Lua table
|
|
attrsetToLuaTable = attrset:
|
|
"{ "
|
|
+ (
|
|
builtins.concatStringsSep ", "
|
|
(builtins.attrValues (
|
|
builtins.mapAttrs (
|
|
name: value:
|
|
attrToKey name + " = " + ("\"" + builtins.toJSON value + "\"")
|
|
)
|
|
attrset
|
|
))
|
|
)
|
|
+ " }";
|
|
}
|