diff --git a/lua/go/format.lua b/lua/go/format.lua index a6cf28c..be467df 100644 --- a/lua/go/format.lua +++ b/lua/go/format.lua @@ -4,9 +4,9 @@ local api = vim.api local utils = require("go.utils") local log = utils.log local max_len = _GO_NVIM_CFG.max_line_len or 120 -local goimport = _GO_NVIM_CFG.goimport ~= nil and _GO_NVIM_CFG.goimport or "gofumports" -local gofmt = _GO_NVIM_CFG.gofmt ~= nil and _GO_NVIM_CFG.gofmt or "gofumpt" -local gofmt_args = _GO_NVIM_CFG.gofmt_args and _GO_NVIM_CFG.gofmt_args +local goimport = _GO_NVIM_CFG.goimport or "gofumports" +local gofmt = _GO_NVIM_CFG.gofmt or "gofumpt" +local gofmt_args = _GO_NVIM_CFG.gofmt_args or {"--max-len=" .. tostring(max_len), "--base-formatter=" .. gofmt} local goimport_args = _GO_NVIM_CFG.goimport_args @@ -115,8 +115,8 @@ M.goimport = function(...) if args and _GO_NVIM_CFG.goimport == 'goimports' then run(args, true, 'goimports') else - utils.copy_array(goimport_args, a) - run({}, true) + -- utils.copy_array(goimport_args, a) + run(goimport_args, true) end end diff --git a/lua/tests/go_fmt_spec.lua b/lua/tests/go_fmt_spec.lua index f3fb079..49a37c1 100644 --- a/lua/tests/go_fmt_spec.lua +++ b/lua/tests/go_fmt_spec.lua @@ -114,6 +114,7 @@ describe("should run gofmt", function() vim.wait(200, function() end) local fmt = vim.fn.join(vim.fn.readfile(path), "\n") + print(vim.inspect(fmt)) -- eq(expected, fmt) eq(1, 1) -- still not working cmd = "bd! " .. path