conform: autoformat on save only for specified filetypes
Enable the autoformat on save only for specified filetypes. By default this is only for lua, similar as LSP is by default only enabled for lua. Based on conform recipe: https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md
This commit is contained in:
parent
b83b2b061c
commit
dca3a7f8b9
1 changed files with 10 additions and 4 deletions
14
init.lua
14
init.lua
|
@ -607,10 +607,16 @@ require('lazy').setup {
|
||||||
'stevearc/conform.nvim',
|
'stevearc/conform.nvim',
|
||||||
opts = {
|
opts = {
|
||||||
notify_on_error = false,
|
notify_on_error = false,
|
||||||
format_on_save = {
|
format_on_save = function(bufnr)
|
||||||
timeout_ms = 500,
|
-- Enable format on save for specified filetypes
|
||||||
lsp_fallback = true,
|
local enable_filetypes = { 'lua' }
|
||||||
},
|
if vim.tbl_contains(enable_filetypes, vim.bo[bufnr].filetype) then
|
||||||
|
return {
|
||||||
|
timeout_ms = 500,
|
||||||
|
lsp_fallback = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end,
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { 'stylua' },
|
lua = { 'stylua' },
|
||||||
-- Conform can also run multiple formatters sequentially
|
-- Conform can also run multiple formatters sequentially
|
||||||
|
|
Loading…
Reference in a new issue