fix(conform): changes for new conform.nvim config

This commit is contained in:
Folke Lemaitre 2024-07-20 17:14:07 +02:00
parent 3d1f961232
commit eed91a3e4c
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -1,6 +1,6 @@
local M = {}
---@param opts ConformOpts
---@param opts conform.setupOpts
function M.setup(_, opts)
for _, key in ipairs({ "format_on_save", "format_after_save" }) do
if opts[key] then
@ -10,6 +10,10 @@ function M.setup(_, opts)
opts[key] = nil
end
end
---@diagnostic disable-next-line: undefined-field
if opts.format then
LazyVim.warn("**conform.nvim** `opts.format` is deprecated. Please use `opts.default_format_opts` instead.")
end
require("conform").setup(opts)
end
@ -37,8 +41,7 @@ return {
priority = 100,
primary = true,
format = function(buf)
local opts = LazyVim.opts("conform.nvim")
require("conform").format(LazyVim.merge({}, opts.format, { bufnr = buf }))
require("conform").format({ bufnr = buf })
end,
sources = function(buf)
local ret = require("conform").list_formatters(buf)
@ -59,16 +62,14 @@ return {
"Please refer to the docs at https://www.lazyvim.org/plugins/formatting",
}, { title = "LazyVim" })
end
---@class ConformOpts
---@type conform.setupOpts
local opts = {
-- LazyVim will use these options when formatting with the conform.nvim formatter
format = {
default_format_opts = {
timeout_ms = 3000,
async = false, -- not recommended to change
quiet = false, -- not recommended to change
lsp_format = "fallback", -- not recommended to change
},
---@type table<string, conform.FormatterUnit[]>
formatters_by_ft = {
lua = { "stylua" },
fish = { "fish_indent" },