mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-30 20:44:35 +02:00
feat(format): use conform as lsp formatter since it has better format diffs
This commit is contained in:
parent
ea4174d460
commit
4584410e76
1 changed files with 11 additions and 3 deletions
|
@ -104,9 +104,17 @@ end
|
||||||
|
|
||||||
---@param opts? {filter?: lsp.Client.filter, bufnr?: number}
|
---@param opts? {filter?: lsp.Client.filter, bufnr?: number}
|
||||||
function M.format(opts)
|
function M.format(opts)
|
||||||
vim.lsp.buf.format(
|
opts = vim.tbl_deep_extend("force", {}, opts or {}, require("lazyvim.util").opts("nvim-lspconfig").format or {})
|
||||||
vim.tbl_deep_extend("force", opts or {}, require("lazyvim.util").opts("nvim-lspconfig").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)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue