feat(nvim): debounce lsp server notification
Some checks failed
Check Formatting of Files / Check-Formatting (push) Has been cancelled

This commit is contained in:
Price Hiller 2024-09-11 14:40:50 -05:00
parent 22b9956f90
commit 6aec324b7e
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB

View File

@ -281,6 +281,7 @@ return {
config = function() config = function()
local lsp_capabilities = local lsp_capabilities =
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
local db_timer = vim.uv.new_timer()
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args) callback = function(args)
local bufnr = args.buf local bufnr = args.buf
@ -288,17 +289,32 @@ return {
if not client then if not client then
return return
end end
vim.notify("Attached server `" .. client.name .. "`", vim.log.levels.INFO, { if not db_timer:is_active() then
title = "LSP", local last_clients = {}
---@param win integer The window handle db_timer:start(
on_open = function(win) 100,
vim.api.nvim_set_option_value( 100,
"filetype", vim.schedule_wrap(function()
"markdown", local cur_clients = vim.lsp.get_clients({ bufnr = bufnr })
{ buf = vim.api.nvim_win_get_buf(win) } if #cur_clients > #last_clients then
) last_clients = cur_clients
end, end
}) local messages = {}
for _, cur_client in ipairs(cur_clients) do
table.insert(messages, "- `" .. cur_client.name .. "`")
end
vim.notify(table.concat(messages, "\n"), vim.log.levels.INFO, {
title = "LSP Attached Servers",
---@param win integer The window handle
on_open = function(win)
vim.bo[vim.api.nvim_win_get_buf(win)].filetype = "markdown"
end,
})
db_timer:stop()
end)
)
end
local function disable_format_capability(capabilities) local function disable_format_capability(capabilities)
capabilities.documentFormattingProvider = false capabilities.documentFormattingProvider = false