From 6a096bf9a22903c92f0065ba3316d3821ddd8b72 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 10 May 2024 15:28:03 +0300 Subject: [PATCH] convert string to raw in the pipe join --- lib.nix | 2 +- lib.test.nix | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib.nix b/lib.nix index 9395260..d332d34 100644 --- a/lib.nix +++ b/lib.nix @@ -59,7 +59,7 @@ let else validationError expr "is not supported for a join type"; concat = join ""; - pipe = join "."; + pipe = args: join "." (map (a: if isString a then raw a else a) args); pipe1 = lft: rgt: pipe [ lft rgt ]; spaceBetween = join " "; diff --git a/lib.test.nix b/lib.test.nix index 48c3b66..a4c2c74 100644 --- a/lib.test.nix +++ b/lib.test.nix @@ -153,6 +153,15 @@ with nix2lua; pkgs.lib.runTests { ]); expected = "require(\"nvim-treesitter.parsers\").get_parser_configs()"; }; + "test returns a pipe that convert string to var" = { + expr = toLua (pipe [ + (require "nvim-tree.api") + "config" + "mappings" + (call "default_on_attach" (var "bufnr")) + ]); + expected = "require(\"nvim-tree.api\").config.mappings.default_on_attach(bufnr)"; + }; "test returns lua with setting value to the variable" = { expr = toLua (set "parser_config.d2" { }); expected = "parser_config.d2 = { }";