fix(lsp): auto format use sync
This commit is contained in:
parent
b7c05ecab7
commit
9366f6072c
2 changed files with 8 additions and 7 deletions
|
@ -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 = {
|
||||||
|
|
||||||
|
@ -20,18 +21,18 @@ config.lsp = {
|
||||||
-- enable non-default servers (todo: support for custom server configs)
|
-- enable non-default servers (todo: support for custom server configs)
|
||||||
rust_analyzer = true,
|
rust_analyzer = true,
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue