format_on_save not work with the list of filetypes
vanarok opened this issue · comments
Ivan Isekeev commented
format_on_save does not rocognize list, i.e any list means true for all file types.
I looked into this issue and got good result neovim/neovim#18617
local config = {lsp = {format_on_save={'*.ts','*.html','*.lua'}}}
if config.lsp.format_on_save then
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = config.lsp.format_on_save,
callback = function()
vim.lsp.buf.format({
timeout_ms = config.lsp.format_timeout,
-- check user config to see if we can format on save
filter = function(client)
if config.lsp.can_client_format(client.name) then
return client.name
end
end,
})
end,
group = group,
nested = true,
})
end