mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
fix(conform): changes for new conform.nvim config
This commit is contained in:
parent
3d1f961232
commit
eed91a3e4c
1 changed files with 8 additions and 7 deletions
|
@ -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" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue