sbdchd / neoformat

:sparkles: A (Neo)vim plugin for formatting code.
BSD 2-Clause "Simplified" License
1.97k stars 188 forks source link

clang-format used when formatter fails in some filetypes #452

Open wilfredjonathanjames opened 1 year ago

wilfredjonathanjames commented 1 year ago

Often when I attempt to format certain filetypes that contain a syntax error, Neoformat mangles everything with clang-format. When my desired formatter fails to run, clang-format is used as a fallback.

Doesn't happen in languages like Rust that don't have clang-format defined as a default fallback.

If I have an error, I would only like to see that my chosen linter failed to run. I don't want clang-format attempting to rewrite my broken typescript file.

I've solved this with the following:

vim.g.neoformat_enabled_cpp = { "uncrustify" }
vim.g.neoformat_enabled_javascript = { "prettier" }
vim.g.neoformat_enabled_typescript = { "prettier" }
vim.g.neoformat_enabled_typescriptreact = { "prettier" }

I'm raising this in case anyone else has the same issue, but can I suggest a usability improvement; a configuration flag to make Neoformat not attempt other formatters if a formatter is installed but fails.