Skip to content

Commit

Permalink
fix(#24): ensure augroups for server could have been created when try…
Browse files Browse the repository at this point in the history
…ing to delete them

Signed-off-by: Daniel Nehrig <[email protected]>
  • Loading branch information
danielnehrig committed Jun 26, 2024
1 parent f219146 commit 203022d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lua/config/core/autocmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,16 @@ function M.autocmds()
vim.api.nvim_create_autocmd("LspDetach", {
group = "LspAttach_inlayhints",
callback = function(args)
if not (args.data and args.data.client_id) then
return
end

local client = vim.lsp.get_client_by_id(args.data.client_id)
vim.api.nvim_del_augroup_by_name("lsp_" .. client.name)
-- fixes the case where we do not create augroups when documentHighlight is not supported
-- so we check if the client supports it before deleting the augroup to align with the logic in LspAttach
if client.supports_method("textDocument/documentHighlight") then
vim.api.nvim_del_augroup_by_name("lsp_" .. client.name)
end
end,
})

Expand Down

0 comments on commit 203022d

Please sign in to comment.