41 lines
1.1 KiB
Lua
41 lines
1.1 KiB
Lua
return {
|
|
'stevearc/conform.nvim',
|
|
event = { 'BufWritePre' },
|
|
cmd = { 'ConformInfo' },
|
|
keys = {
|
|
{
|
|
'<leader>f',
|
|
function()
|
|
require('conform').format { async = true, lsp_format = 'fallback' }
|
|
end,
|
|
mode = '',
|
|
desc = '[F]ormat buffer',
|
|
},
|
|
},
|
|
opts = {
|
|
notify_on_error = false,
|
|
format_on_save = function(bufnr)
|
|
-- Skip special buffers (e.g. CodeCompanion chat, terminals)
|
|
if vim.bo[bufnr].buftype ~= '' then
|
|
return nil
|
|
end
|
|
local disable_filetypes = {}
|
|
if disable_filetypes[vim.bo[bufnr].filetype] then
|
|
return nil
|
|
end
|
|
return { timeout_ms = 500, lsp_format = 'fallback' }
|
|
end,
|
|
formatters_by_ft = {
|
|
lua = { 'stylua' },
|
|
c = { 'clang-format' },
|
|
cpp = { 'clang-format' },
|
|
python = { 'isort', 'black' },
|
|
go = { 'goimports', 'gofmt' },
|
|
java = { 'google-java-format' },
|
|
html = { 'prettier' },
|
|
css = { 'prettier' },
|
|
markdown = { 'prettier' },
|
|
toml = { 'taplo' },
|
|
},
|
|
},
|
|
}
|