fix(nvim): change callback to format go code
This commit is contained in:
parent
d842522112
commit
9b1f7ce69b
1 changed files with 8 additions and 7 deletions
|
@ -17,15 +17,16 @@ end
|
||||||
|
|
||||||
function format_with_imports(timeout_ms)
|
function format_with_imports(timeout_ms)
|
||||||
OrgImports(1000)
|
OrgImports(1000)
|
||||||
vim.lsp.buf.formatting()
|
vim.lsp.buf.format()
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.cmd [[
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
augroup gopls
|
pattern = '*.go',
|
||||||
autocmd!
|
callback = function()
|
||||||
autocmd BufWritePre *.go lua format_with_imports(1000, "utf-16")
|
vim.lsp.buf.code_action({ context = { only = { 'source.organizeImports' } }, apply = true })
|
||||||
augroup END
|
vim.lsp.buf.format()
|
||||||
]]
|
end
|
||||||
|
})
|
||||||
|
|
||||||
require('lspconfig').gopls.setup {
|
require('lspconfig').gopls.setup {
|
||||||
capabilities = common.cap,
|
capabilities = common.cap,
|
||||||
|
|
Loading…
Add table
Reference in a new issue