fix(lsp): dont try to highlight refs for deleted buffers

This commit is contained in:
Folke Lemaitre 2024-05-17 10:07:49 +02:00
parent 47c90209f3
commit 87493af237
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -135,6 +135,14 @@ function M.words.setup(opts)
if not opts.enabled then
return
end
local handler = vim.lsp.handlers["textDocument/documentHighlight"]
vim.lsp.handlers["textDocument/documentHighlight"] = function(err, result, ctx, config)
if not vim.api.nvim_buf_is_loaded(ctx.bufnr) then
return
end
return handler(err, result, ctx, config)
end
M.on_attach(function(client, buf)
if client.supports_method("textDocument/documentHighlight") then
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI" }, {