fix(lsp): auto format use sync

This commit is contained in:
Matt Leong 2021-10-25 11:42:03 -07:00
parent b7c05ecab7
commit 9366f6072c
2 changed files with 8 additions and 7 deletions

View file

@ -1,6 +1,7 @@
-- Override Cosmic configuration options -- Override Cosmic configuration options
--[[ --[[
local config = {} local config = {}
config.statusline = { config.statusline = {
@ -10,7 +11,7 @@ config.statusline = {
config.lsp = { config.lsp = {
-- true/false or table of filetypes {'.ts', '.js',} -- true/false or table of filetypes {'.ts', '.js',}
format_on_save = false, format_on_save = true,
servers = { servers = {
@ -23,15 +24,15 @@ config.lsp = {
tsserver = { tsserver = {
-- disable formatting -- disable formatting
format = false, format = false,
} },
efm = { efm = {
-- specifc to efm, e.g. 'eslint', 'prettier', 'stylua' -- specifc to efm, e.g. 'eslint', 'prettier', 'stylua'
disable_formatters = {}, disable_formatters = {'eslint'},
},
}, },
}
} }
return config return config
]] ]]

View file

@ -25,7 +25,7 @@ function M.on_attach(client, bufnr)
else else
format_filetypes = '*' format_filetypes = '*'
end end
vim.cmd(string.format('autocmd BufWritePre %s lua vim.lsp.buf.formatting()', format_filetypes)) vim.cmd(string.format('autocmd BufWritePre %s lua vim.lsp.buf.formatting_sync(nil, 1000)', format_filetypes))
end end
else else
client.resolved_capabilities.document_formatting = false client.resolved_capabilities.document_formatting = false