From ab8f0527a1c54e654436a93ae45232d5d2e4a8e4 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Fri, 21 Aug 2026 06:34:18 +0000 Subject: [PATCH 1/2] fix(config): preserve explicit go command --- lua/glaze/init.lua | 3 ++- tests/run.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lua/glaze/init.lua b/lua/glaze/init.lua index 41d17e4..4357066 100644 --- a/lua/glaze/init.lua +++ b/lua/glaze/init.lua @@ -120,11 +120,12 @@ end ---@param opts? GlazeConfig function M.setup(opts) + local should_detect_goenv = not opts or opts.go_cmd == nil M.config = vim.tbl_deep_extend("force", M.config, opts or {}) M._ns = vim.api.nvim_create_namespace("glaze") -- Auto-detect goenv - if vim.fn.executable("goenv") == 1 then + if should_detect_goenv and vim.fn.executable("goenv") == 1 then M.config.go_cmd = { "goenv", "exec", "go" } end diff --git a/tests/run.lua b/tests/run.lua index b82de28..180e55a 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -56,6 +56,46 @@ test("setup is idempotent and preserves updated config", function() assert_truthy(vim.fn.exists(":GlazeCheck") == 2, "GlazeCheck command should exist") end) +test("setup preserves explicit go command when goenv is installed", function() + local glaze = reset_glaze() + local original_executable = vim.fn.executable + + vim.fn.executable = function(name) + if name == "goenv" then + return 1 + end + return original_executable(name) + end + + glaze.setup({ + auto_check = { enabled = false }, + go_cmd = { "custom-go", "wrapper" }, + }) + vim.fn.executable = original_executable + + assert_eq(glaze.config.go_cmd[1], "custom-go", "explicit go command should not be replaced by goenv") + assert_eq(glaze.config.go_cmd[2], "wrapper", "explicit go command arguments should be preserved") +end) + +test("setup auto-detects goenv when go command is omitted", function() + local glaze = reset_glaze() + local original_executable = vim.fn.executable + + vim.fn.executable = function(name) + if name == "goenv" then + return 1 + end + return original_executable(name) + end + + glaze.setup({ auto_check = { enabled = false } }) + vim.fn.executable = original_executable + + assert_eq(glaze.config.go_cmd[1], "goenv", "omitted go command should use detected goenv") + assert_eq(glaze.config.go_cmd[2], "exec", "goenv command should include exec") + assert_eq(glaze.config.go_cmd[3], "go", "goenv command should run go") +end) + test("register batches auto-install requests into one install call", function() local glaze = reset_glaze() local runner = require("glaze.runner") From 24cad5e9b0c5a6eef8f69487a36562e1e8eaa9ce Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sat, 22 Aug 2026 19:30:00 -0400 Subject: [PATCH 2/2] fix(config): replace go_cmd wholesale to avoid stale list merge vim.tbl_deep_extend merges lists by index, so a later setup() with a shorter explicit go_cmd could retain stale trailing elements from a prior goenv-detected value. Replace go_cmd outright and add regression coverage. --- lua/glaze/init.lua | 6 ++++++ tests/run.lua | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lua/glaze/init.lua b/lua/glaze/init.lua index 4357066..bb439dc 100644 --- a/lua/glaze/init.lua +++ b/lua/glaze/init.lua @@ -124,6 +124,12 @@ function M.setup(opts) M.config = vim.tbl_deep_extend("force", M.config, opts or {}) M._ns = vim.api.nvim_create_namespace("glaze") + -- go_cmd is a list; replace it wholesale so index-wise deep merge cannot + -- leave stale trailing elements from a previous value. + if opts and opts.go_cmd ~= nil then + M.config.go_cmd = vim.deepcopy(opts.go_cmd) + end + -- Auto-detect goenv if should_detect_goenv and vim.fn.executable("goenv") == 1 then M.config.go_cmd = { "goenv", "exec", "go" } diff --git a/tests/run.lua b/tests/run.lua index 180e55a..a65f015 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -96,6 +96,25 @@ test("setup auto-detects goenv when go command is omitted", function() assert_eq(glaze.config.go_cmd[3], "go", "goenv command should run go") end) +test("setup replaces goenv-detected go command wholesale on later explicit setup", function() + local glaze = reset_glaze() + local original_executable = vim.fn.executable + + vim.fn.executable = function(name) + if name == "goenv" then + return 1 + end + return original_executable(name) + end + + glaze.setup({ auto_check = { enabled = false } }) + glaze.setup({ go_cmd = { "go" } }) + vim.fn.executable = original_executable + + assert_eq(#glaze.config.go_cmd, 1, "explicit go command should not retain stale trailing elements") + assert_eq(glaze.config.go_cmd[1], "go", "explicit go command should be used verbatim") +end) + test("register batches auto-install requests into one install call", function() local glaze = reset_glaze() local runner = require("glaze.runner")