Feat: support format on save

- use conform to format file
This commit is contained in:
flea 2024-02-07 17:20:35 +08:00
parent 6e9cf88b96
commit 71e9c28bf7
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
return {
'stevearc/conform.nvim',
event = { 'BufReadPre', 'BufNewFile' },
opts = {
formatters_by_ft = {
lua = { 'stylua' },
python = function(bufnr)
if require('conform').get_formatter_info('ruff_format', bufnr).available then
return { 'ruff_format' }
else
return { 'isort', 'black' }
end
end,
},
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
},
}