default to not format on save, except for explicitly listed filetypes
This commit is contained in:
parent
bd7eb9be0f
commit
bc0cf8961e
|
@ -16,15 +16,17 @@ return {
|
||||||
opts = {
|
opts = {
|
||||||
notify_on_error = false,
|
notify_on_error = false,
|
||||||
format_on_save = function(bufnr)
|
format_on_save = function(bufnr)
|
||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
-- Filetypes to apply formatting to on save. Remove from this list
|
||||||
-- have a well standardized coding style. You can add additional
|
-- to disable formatting on save for that filetype.
|
||||||
-- languages here or re-enable it for the disabled ones.
|
local filetypes = {
|
||||||
local disable_filetypes = { c = true, cpp = true }
|
'lua',
|
||||||
|
'rust',
|
||||||
|
}
|
||||||
local lsp_format_opt
|
local lsp_format_opt
|
||||||
if disable_filetypes[vim.bo[bufnr].filetype] then
|
if filetypes[vim.bo[bufnr].filetype] then
|
||||||
lsp_format_opt = 'never'
|
|
||||||
else
|
|
||||||
lsp_format_opt = 'fallback'
|
lsp_format_opt = 'fallback'
|
||||||
|
else
|
||||||
|
lsp_format_opt = 'never'
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
timeout_ms = 500,
|
timeout_ms = 500,
|
||||||
|
|
Loading…
Reference in a new issue