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 = {}
|
local M = {}
|
||||||
|
|
||||||
---@param opts ConformOpts
|
---@param opts conform.setupOpts
|
||||||
function M.setup(_, opts)
|
function M.setup(_, opts)
|
||||||
for _, key in ipairs({ "format_on_save", "format_after_save" }) do
|
for _, key in ipairs({ "format_on_save", "format_after_save" }) do
|
||||||
if opts[key] then
|
if opts[key] then
|
||||||
|
@ -10,6 +10,10 @@ function M.setup(_, opts)
|
||||||
opts[key] = nil
|
opts[key] = nil
|
||||||
end
|
end
|
||||||
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)
|
require("conform").setup(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,8 +41,7 @@ return {
|
||||||
priority = 100,
|
priority = 100,
|
||||||
primary = true,
|
primary = true,
|
||||||
format = function(buf)
|
format = function(buf)
|
||||||
local opts = LazyVim.opts("conform.nvim")
|
require("conform").format({ bufnr = buf })
|
||||||
require("conform").format(LazyVim.merge({}, opts.format, { bufnr = buf }))
|
|
||||||
end,
|
end,
|
||||||
sources = function(buf)
|
sources = function(buf)
|
||||||
local ret = require("conform").list_formatters(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",
|
"Please refer to the docs at https://www.lazyvim.org/plugins/formatting",
|
||||||
}, { title = "LazyVim" })
|
}, { title = "LazyVim" })
|
||||||
end
|
end
|
||||||
---@class ConformOpts
|
---@type conform.setupOpts
|
||||||
local opts = {
|
local opts = {
|
||||||
-- LazyVim will use these options when formatting with the conform.nvim formatter
|
default_format_opts = {
|
||||||
format = {
|
|
||||||
timeout_ms = 3000,
|
timeout_ms = 3000,
|
||||||
async = false, -- not recommended to change
|
async = false, -- not recommended to change
|
||||||
quiet = false, -- not recommended to change
|
quiet = false, -- not recommended to change
|
||||||
lsp_format = "fallback", -- not recommended to change
|
lsp_format = "fallback", -- not recommended to change
|
||||||
},
|
},
|
||||||
---@type table<string, conform.FormatterUnit[]>
|
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { "stylua" },
|
lua = { "stylua" },
|
||||||
fish = { "fish_indent" },
|
fish = { "fish_indent" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue