Highlight references to current word

This commit is contained in:
Dreaded_X 2024-04-16 03:51:55 +02:00
parent f37e2a26dd
commit a0ec7e7784
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
2 changed files with 16 additions and 0 deletions

View File

@ -79,6 +79,19 @@ return {
-- Lesser used LSP functionality -- Lesser used LSP functionality
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf,
callback = vim.lsp.buf.clear_references,
})
end
end, end,
}) })

View File

@ -32,6 +32,9 @@ return {
CmpItemAbbrMatchFuzzy = { fg = colors.aqua, bold = true }, CmpItemAbbrMatchFuzzy = { fg = colors.aqua, bold = true },
CmpItemMenu = { fg = colors.bg2 }, CmpItemMenu = { fg = colors.bg2 },
CmpItemKindFunction = { fg = colors.red }, CmpItemKindFunction = { fg = colors.red },
LspReferenceText = { fg = colors.bg0, bg = colors.neutral_purple },
LspReferenceRead = { link = "LspReferenceText" },
LspReferenceWrite = { link = "LspReferenceText" },
}, },
}) })