mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -1,46 +1,44 @@
|
|||
{lib}:
|
||||
with lib; rec {
|
||||
{ lib }:
|
||||
with lib;
|
||||
rec {
|
||||
# Black functional magic that converts a bunch of different Nix types to their
|
||||
# lua equivalents!
|
||||
toLuaObject = args:
|
||||
if builtins.isAttrs args
|
||||
then
|
||||
if hasAttr "__raw" args
|
||||
then args.__raw
|
||||
else if hasAttr "__empty" args
|
||||
then "{ }"
|
||||
toLuaObject =
|
||||
args:
|
||||
if builtins.isAttrs args then
|
||||
if hasAttr "__raw" args then
|
||||
args.__raw
|
||||
else if hasAttr "__empty" args then
|
||||
"{ }"
|
||||
else
|
||||
"{"
|
||||
+ (concatStringsSep ","
|
||||
(mapAttrsToList
|
||||
(n: v:
|
||||
if (builtins.match "__unkeyed.*" n) != null
|
||||
then toLuaObject v
|
||||
else if n == "__emptyString"
|
||||
then "[''] = " + (toLuaObject v)
|
||||
else "[${toLuaObject n}] = " + (toLuaObject v))
|
||||
(filterAttrs
|
||||
(
|
||||
n: v:
|
||||
v != null && (toLuaObject v != "{}")
|
||||
)
|
||||
args)))
|
||||
+ (concatStringsSep "," (
|
||||
mapAttrsToList (
|
||||
n: v:
|
||||
if (builtins.match "__unkeyed.*" n) != null then
|
||||
toLuaObject v
|
||||
else if n == "__emptyString" then
|
||||
"[''] = " + (toLuaObject v)
|
||||
else
|
||||
"[${toLuaObject n}] = " + (toLuaObject v)
|
||||
) (filterAttrs (n: v: v != null && (toLuaObject v != "{}")) args)
|
||||
))
|
||||
+ "}"
|
||||
else if builtins.isList args
|
||||
then "{" + concatMapStringsSep "," toLuaObject args + "}"
|
||||
else if builtins.isString args
|
||||
then
|
||||
else if builtins.isList args then
|
||||
"{" + concatMapStringsSep "," toLuaObject args + "}"
|
||||
else if builtins.isString args then
|
||||
# This should be enough!
|
||||
builtins.toJSON args
|
||||
else if builtins.isPath args
|
||||
then builtins.toJSON (toString args)
|
||||
else if builtins.isBool args
|
||||
then "${boolToString args}"
|
||||
else if builtins.isFloat args
|
||||
then "${toString args}"
|
||||
else if builtins.isInt args
|
||||
then "${toString args}"
|
||||
else if (args == null)
|
||||
then "nil"
|
||||
else "";
|
||||
else if builtins.isPath args then
|
||||
builtins.toJSON (toString args)
|
||||
else if builtins.isBool args then
|
||||
"${boolToString args}"
|
||||
else if builtins.isFloat args then
|
||||
"${toString args}"
|
||||
else if builtins.isInt args then
|
||||
"${toString args}"
|
||||
else if (args == null) then
|
||||
"nil"
|
||||
else
|
||||
"";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue