This commit is contained in:
ray-x 2022-05-31 16:16:09 +10:00
parent 56143544d7
commit f5f5c41165
3 changed files with 18 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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