mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 00:49:03 +02:00
feat(lsp): added nvim-lspconfig.opts.format_notify
. Enable this to debug formatter issues.
This commit is contained in:
parent
962fc6bab4
commit
5eccaeb992
2 changed files with 41 additions and 0 deletions
|
@ -47,6 +47,44 @@ function M.format(opts)
|
||||||
}, require("lazyvim.util").opts("nvim-lspconfig").format or {}))
|
}, require("lazyvim.util").opts("nvim-lspconfig").format or {}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param formatters LazyVimFormatters
|
||||||
|
function M.notify(formatters)
|
||||||
|
local lines = { "# Active:" }
|
||||||
|
|
||||||
|
for _, client in ipairs(formatters.active) do
|
||||||
|
local line = "- **" .. client.name .. "**"
|
||||||
|
if client.name == "null-ls" then
|
||||||
|
line = line
|
||||||
|
.. " ("
|
||||||
|
.. table.concat(
|
||||||
|
vim.tbl_map(function(f)
|
||||||
|
return "`" .. f.name .. "`"
|
||||||
|
end, formatters.null_ls),
|
||||||
|
", "
|
||||||
|
)
|
||||||
|
.. ")"
|
||||||
|
end
|
||||||
|
table.insert(lines, line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if #formatters.available > 0 then
|
||||||
|
table.insert(lines, "")
|
||||||
|
table.insert(lines, "# Disabled:")
|
||||||
|
for _, client in ipairs(formatters.available) do
|
||||||
|
table.insert(lines, "- **" .. client.name .. "**")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.notify(table.concat(lines, "\n"), vim.log.levels.INFO, {
|
||||||
|
title = "Formatting",
|
||||||
|
on_open = function(win)
|
||||||
|
vim.api.nvim_win_set_option(win, "conceallevel", 3)
|
||||||
|
vim.api.nvim_win_set_option(win, "spell", false)
|
||||||
|
local buf = vim.api.nvim_win_get_buf(win)
|
||||||
|
vim.treesitter.start(buf, "markdown")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
-- Gets all lsp clients that support formatting.
|
-- Gets all lsp clients that support formatting.
|
||||||
-- When a null-ls formatter is available for the current filetype,
|
-- When a null-ls formatter is available for the current filetype,
|
||||||
|
|
|
@ -35,6 +35,9 @@ return {
|
||||||
capabilities = {},
|
capabilities = {},
|
||||||
-- Automatically format on save
|
-- Automatically format on save
|
||||||
autoformat = true,
|
autoformat = true,
|
||||||
|
-- Enable this to show formatters used in a notification
|
||||||
|
-- Useful for debugging formatter issues
|
||||||
|
format_notify = false,
|
||||||
-- options for vim.lsp.buf.format
|
-- options for vim.lsp.buf.format
|
||||||
-- `bufnr` and `filter` is handled by the LazyVim formatter,
|
-- `bufnr` and `filter` is handled by the LazyVim formatter,
|
||||||
-- but can be also overridden when specified
|
-- but can be also overridden when specified
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue