mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-23 21:09:48 +01:00
Merge pull request #226 from horriblename/fix-lua-null-conversion
Fix lua null conversion
This commit is contained in:
commit
cd4d0cd63d
1 changed files with 5 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Helpers for converting values to lua
|
# Helpers for converting values to lua
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib) mapAttrsToList filterAttrs concatStringsSep concatMapStringsSep stringToCharacters boolToString;
|
inherit (lib) mapAttrsToList filterAttrs concatStringsSep concatMapStringsSep stringToCharacters boolToString;
|
||||||
inherit (builtins) hasAttr head;
|
inherit (builtins) hasAttr head throw typeOf;
|
||||||
in rec {
|
in rec {
|
||||||
# Convert a null value to lua's nil
|
# Convert a null value to lua's nil
|
||||||
nullString = value:
|
nullString = value:
|
||||||
|
@ -19,6 +19,8 @@ in rec {
|
||||||
then lib.boolToString exp # if bool, convert to string
|
then lib.boolToString exp # if bool, convert to string
|
||||||
else if builtins.isInt exp
|
else if builtins.isInt exp
|
||||||
then builtins.toString exp # if int, convert to string
|
then builtins.toString exp # if int, convert to string
|
||||||
|
else if exp == null
|
||||||
|
then "nil"
|
||||||
else (builtins.toJSON exp); # otherwise jsonify the value and print as is
|
else (builtins.toJSON exp); # otherwise jsonify the value and print as is
|
||||||
|
|
||||||
# convert list to a lua table
|
# convert list to a lua table
|
||||||
|
@ -80,7 +82,7 @@ in rec {
|
||||||
then "${toString args}"
|
then "${toString args}"
|
||||||
else if builtins.isInt args
|
else if builtins.isInt args
|
||||||
then "${toString args}"
|
then "${toString args}"
|
||||||
else if (args != null)
|
else if (args == null)
|
||||||
then "nil"
|
then "nil"
|
||||||
else "";
|
else throw "could not convert object of type `${typeOf args}` to lua object";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue