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)
|
||||
OrgImports(1000)
|
||||
vim.lsp.buf.formatting()
|
||||
vim.lsp.buf.format()
|
||||
end
|
||||
|
||||
vim.cmd [[
|
||||
augroup gopls
|
||||
autocmd!
|
||||
autocmd BufWritePre *.go lua format_with_imports(1000, "utf-16")
|
||||
augroup END
|
||||
]]
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
pattern = '*.go',
|
||||
callback = function()
|
||||
vim.lsp.buf.code_action({ context = { only = { 'source.organizeImports' } }, apply = true })
|
||||
vim.lsp.buf.format()
|
||||
end
|
||||
})
|
||||
|
||||
require('lspconfig').gopls.setup {
|
||||
capabilities = common.cap,
|
||||
|
|
Loading…
Add table
Reference in a new issue