From afca0b7876abf9022ee0754270f603e981ea42a5 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis Date: Thu, 14 Mar 2024 15:14:41 +0200 Subject: [PATCH] fix(conform): make `lsp_fallback` option user configurable (#2616) --- lua/lazyvim/plugins/formatting.lua | 1 + lua/lazyvim/util/lsp.lua | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index eb2dd1a8..e1aefe18 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -84,6 +84,7 @@ return { timeout_ms = 3000, async = false, -- not recommended to change quiet = false, -- not recommended to change + lsp_fallback = true, -- not recommended to change }, ---@type table formatters_by_ft = { diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua index b34a2afe..a40e9415 100644 --- a/lua/lazyvim/util/lsp.lua +++ b/lua/lazyvim/util/lsp.lua @@ -109,13 +109,18 @@ end ---@param opts? lsp.Client.format function M.format(opts) - opts = vim.tbl_deep_extend("force", {}, opts or {}, require("lazyvim.util").opts("nvim-lspconfig").format or {}) + opts = vim.tbl_deep_extend( + "force", + {}, + opts or {}, + require("lazyvim.util").opts("nvim-lspconfig").format or {}, + require("lazyvim.util").opts("conform.nvim").format or {} + ) local ok, conform = pcall(require, "conform") -- use conform for formatting with LSP when available, -- since it has better format diffing if ok then opts.formatters = {} - opts.lsp_fallback = true conform.format(opts) else vim.lsp.buf.format(opts)