conform.lua
return {
'stevearc/conform.nvim',
opts = {
formatters_by_ft = {
python = { 'ruff_format', 'ruff_organize_imports' },
lua = { 'stylua' },
-- C/C++: стиль берётся из .clang-format в проекте (если есть)
c = { 'clang-format' },
cpp = { 'clang-format' },
-- Web: prettierd (демон, быстрый), с фолбэком на prettier
javascript = { 'prettierd', 'prettier', stop_after_first = true },
javascriptreact = { 'prettierd', 'prettier', stop_after_first = true },
typescript = { 'prettierd', 'prettier', stop_after_first = true },
typescriptreact = { 'prettierd', 'prettier', stop_after_first = true },
vue = { 'prettierd', 'prettier', stop_after_first = true },
svelte = { 'prettierd', 'prettier', stop_after_first = true },
html = { 'prettierd', 'prettier', stop_after_first = true },
css = { 'prettierd', 'prettier', stop_after_first = true },
scss = { 'prettierd', 'prettier', stop_after_first = true },
less = { 'prettierd', 'prettier', stop_after_first = true },
graphql = { 'prettierd', 'prettier', stop_after_first = true },
json = { 'prettierd', 'prettier', stop_after_first = true },
jsonc = { 'prettierd', 'prettier', stop_after_first = true },
yaml = { 'prettierd', 'prettier', stop_after_first = true },
markdown = { 'prettierd', 'prettier', stop_after_first = true },
},
formatters = {
-- Если в проекте нет .clang-format: стиль LLVM, но с отступом 4 пробела
['clang-format'] = {
prepend_args = function(_, ctx)
if vim.fs.find({ '.clang-format', '_clang-format' }, { path = ctx.dirname, upward = true })[1] then return {} end
return { '--style={BasedOnStyle: LLVM, IndentWidth: 4}' }
end,
},
},
format_on_save = {
timeout_ms = 1000,
lsp_format = 'fallback',
},
},
}