synchronous goimports (#186)

* fix save formatting

* fix vim.lsp.buf.format polyfill

* reformat and default values

* remove extra end

Co-authored-by: rayx <rayx.cn@gmail.com>
pull/196/head
mateusz 2 years ago committed by GitHub
parent a9b669772f
commit 002e199562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -137,9 +137,13 @@ end
M.org_imports = function(wait_ms)
local codeaction = require("go.lsp").codeaction
codeaction("", "source.organizeImports", wait_ms)
vim.defer_fn(function()
vim.lsp.buf.format({ async = _GO_NVIM_CFG.lsp_fmt_async })
end, 100)
if _GO_NVIM_CFG.lsp_fmt_async then
vim.defer_fn(function()
vim.lsp.buf.format({ async = true })
end, 100)
else
vim.lsp.buf.format({ async = false })
end
end
M.goimport = function(...)

@ -8,7 +8,12 @@ end
if vim.lsp.buf.format == nil then
-- neovim < 0.7 only
vim.lsp.buf.format = vim.lsp.buf.formatting
vim.lsp.buf.format = function(options)
if options.async then
vim.lsp.buf.formatting()
else
vim.lsp.buf.formatting_sync()
end
end
local codelens_enabled = false

Loading…
Cancel
Save