Skip to content

Commit

Permalink
fix(formatexpr): does not fallback to the built-in formatexpr (#238)
Browse files Browse the repository at this point in the history
This makes the behavior of formatexpr more consistent with
`vim.lsp.formatexpr`; do not run vim's builtin formatter.

Problem: When conform's formatexpr is used and (range or buffer) but
conform can't do formatting and there is no LSP formatter with the
formatting capabilities, it will fall back to the (wrong) built-in
formatting, which might result in simply concatenating all the words.

This is a breaking change, reverting the behavior introduced in #55.
  • Loading branch information
wookayin committed Dec 8, 2023
1 parent ce95e6b commit 48bc999
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/conform/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ M.formatexpr = function(opts)
-- No formatters were available; fall back to lsp formatter
return vim.lsp.formatexpr({ timeout_ms = opts.timeout_ms })
else
return 1
-- Do not fallback to built-in formatter.
return 0
end
end

Expand Down

0 comments on commit 48bc999

Please sign in to comment.