From 8422cbd128534375a629fdefa2a2286da0e87ba2 Mon Sep 17 00:00:00 2001 From: Ydot19 Date: Thu, 31 Oct 2024 22:36:31 -0500 Subject: [PATCH] Enhance: pass --color argument to neotest adaper --- lua/rustaceanvim/neotest/init.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/rustaceanvim/neotest/init.lua b/lua/rustaceanvim/neotest/init.lua index 2465d177..8f748568 100644 --- a/lua/rustaceanvim/neotest/init.lua +++ b/lua/rustaceanvim/neotest/init.lua @@ -299,8 +299,18 @@ function NeotestAdapter.build_spec(run_args) table.insert(args, insert_pos, '--no-fail-fast') table.insert(args, insert_pos, '--color=never') if is_cargo_test then - -- cargo test needs to pass --color=never to the test runner too - table.insert(args, '--color=never') + -- filter args at any position + local filtered = vim.tbl_filter(function(v) + return string.match(v, '^--color=') + end, runnable.args.cargoArgs) + + if not vim.tbl_isempty(filtered) then + -- add first occurrence of filter argument contain --color + table.insert(args, filtered[0]) + else + -- cargo test needs to pass --color=never to the test runner too + table.insert(args, '--color=never') + end end ---@type rustaceanvim.neotest.RunSpec ---@diagnostic disable-next-line: missing-fields