diff --git a/lua/go/asyncmake.lua b/lua/go/asyncmake.lua index 8dec068..3629b0c 100644 --- a/lua/go/asyncmake.lua +++ b/lua/go/asyncmake.lua @@ -265,9 +265,9 @@ function M.make(...) itemn = 1 if failed then - vim.notify(info .. " succeed", level) - else vim.notify(info .. " failed", level) + else + vim.notify(info .. " succeed", level) end failed = false end diff --git a/lua/go/format.lua b/lua/go/format.lua index 7bd8c0c..c9a5a12 100644 --- a/lua/go/format.lua +++ b/lua/go/format.lua @@ -25,7 +25,7 @@ local run = function(fmtargs, bufnr, cmd) vim.fn.bufload(bufnr) end - api.cmd("write") + vim.cmd("write") vim.lsp.buf.format({ async = _GO_NVIM_CFG.lsp_fmt_async, bufnr = bufnr, name = "gopls" }) return end @@ -36,7 +36,7 @@ local run = function(fmtargs, bufnr, cmd) if bufnr == 0 then if vim.fn.getbufinfo("%")[1].changed == 1 then - api.cmd("write") + vim.cmd("write") end end @@ -71,8 +71,15 @@ local run = function(fmtargs, bufnr, cmd) on_exit = function(id, data, event) -- log(vim.inspect(data) .. "exit") -- log("current data " .. vim.inspect(new_lines)) + if data.code ~= 0 then + return vim.notify("golines failed " .. tostring(data), vim.lsp.log_levels.ERROR) + end old_lines = nil - vim.cmd("write") + vim.defer_fn(function() + if vim.fn.getbufinfo("%")[1].changed == 1 then + vim.cmd("write") + end + end, 300) end, stdout_buffered = true, stderr_buffered = true, @@ -114,7 +121,9 @@ M.gofmt = function(...) run(a, b.bufnr) end else - vim.cmd("write") + if vim.fn.getbufinfo("%")[1].changed == 1 then + vim.cmd("write") + end run(a, 0) end end diff --git a/lua/go/term.lua b/lua/go/term.lua index b57d495..72980d3 100644 --- a/lua/go/term.lua +++ b/lua/go/term.lua @@ -30,13 +30,13 @@ local term = function(opts) if columns > 140 then -- split in right win_height = math.ceil(lines * 0.98) - win_width = math.ceil(columns * 0.3) - win_width = math.max(70, win_width) + win_width = math.ceil(columns * 0.45) + win_width = math.max(80, win_width) opts.y = win_height opts.x = columns - win_width else - win_height = math.ceil(lines * 0.3) + win_height = math.ceil(lines * 0.45) win_width = math.ceil(columns * 0.98) opts.y = opts.y or lines - win_height