fix(format): set formatexpr in options so users can override it. Fixes #1759
This commit is contained in:
@ -87,5 +87,7 @@ else
|
|||||||
vim.opt.foldmethod = "indent"
|
vim.opt.foldmethod = "indent"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
vim.o.formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()"
|
||||||
|
|
||||||
-- Fix markdown indentation settings
|
-- Fix markdown indentation settings
|
||||||
vim.g.markdown_recommended_style = 0
|
vim.g.markdown_recommended_style = 0
|
||||||
|
@ -50,7 +50,6 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
init = function()
|
init = function()
|
||||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
|
||||||
-- Install the conform formatter on VeryLazy
|
-- Install the conform formatter on VeryLazy
|
||||||
require("lazyvim.util").on_very_lazy(function()
|
require("lazyvim.util").on_very_lazy(function()
|
||||||
require("lazyvim.util").format.register({
|
require("lazyvim.util").format.register({
|
||||||
|
@ -25,6 +25,13 @@ function M.register(formatter)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.formatexpr()
|
||||||
|
if Util.has("conform.nvim") then
|
||||||
|
return require("conform").formatexpr()
|
||||||
|
end
|
||||||
|
return vim.lsp.formatexpr({ timeout_ms = 3000 })
|
||||||
|
end
|
||||||
|
|
||||||
---@param buf? number
|
---@param buf? number
|
||||||
---@return (LazyFormatter|{active:boolean,resolved:string[]})[]
|
---@return (LazyFormatter|{active:boolean,resolved:string[]})[]
|
||||||
function M.resolve(buf)
|
function M.resolve(buf)
|
||||||
@ -67,7 +74,7 @@ function M.info(buf)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not have then
|
if not have then
|
||||||
lines[#lines+1] = "\n***No formatters available for this buffer.***"
|
lines[#lines + 1] = "\n***No formatters available for this buffer.***"
|
||||||
end
|
end
|
||||||
Util[enabled and "info" or "warn"](
|
Util[enabled and "info" or "warn"](
|
||||||
table.concat(lines, "\n"),
|
table.concat(lines, "\n"),
|
||||||
|
Reference in New Issue
Block a user