fix(lsp): dont highlight document words when cmp is visible

This commit is contained in:
Folke Lemaitre 2024-06-16 15:17:45 +02:00
parent 32b2574c1b
commit 0d57115f01
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 7 additions and 1 deletions

View file

@ -70,6 +70,11 @@ function M.add_missing_snippet_docs(window)
end end
end end
function M.visible()
local ok, cmp = pcall(require, "cmp")
return ok and cmp.core.view:visible()
end
-- This is a better implementation of `cmp.confirm`: -- This is a better implementation of `cmp.confirm`:
-- * check if the completion menu is visible without waiting for running sources -- * check if the completion menu is visible without waiting for running sources
-- * create an undo point before confirming -- * create an undo point before confirming

View file

@ -280,10 +280,11 @@ function M.words.setup(opts)
if not require("lazyvim.plugins.lsp.keymaps").has(buf, "documentHighlight") then if not require("lazyvim.plugins.lsp.keymaps").has(buf, "documentHighlight") then
return false return false
end end
if not ({ M.words.get() })[2] then if not ({ M.words.get() })[2] then
if ev.event:find("CursorMoved") then if ev.event:find("CursorMoved") then
vim.lsp.buf.clear_references() vim.lsp.buf.clear_references()
else elseif not LazyVim.cmp.visible() then
vim.lsp.buf.document_highlight() vim.lsp.buf.document_highlight()
end end
end end