fix(format): set formatexpr in options so users can override it. Fixes #1759

This commit is contained in:
Folke Lemaitre 2023-10-16 23:01:18 +02:00
parent fef0b3f756
commit ff64cc5399
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 10 additions and 2 deletions

View file

@ -25,6 +25,13 @@ function M.register(formatter)
end)
end
function M.formatexpr()
if Util.has("conform.nvim") then
return require("conform").formatexpr()
end
return vim.lsp.formatexpr({ timeout_ms = 3000 })
end
---@param buf? number
---@return (LazyFormatter|{active:boolean,resolved:string[]})[]
function M.resolve(buf)
@ -67,7 +74,7 @@ function M.info(buf)
end
end
if not have then
lines[#lines+1] = "\n***No formatters available for this buffer.***"
lines[#lines + 1] = "\n***No formatters available for this buffer.***"
end
Util[enabled and "info" or "warn"](
table.concat(lines, "\n"),