Add nvim document-highlight lua module

This commit is contained in:
Talia 2024-07-08 13:28:47 +02:00
parent dba8c3f6e8
commit 802b5ba4d1

View file

@ -0,0 +1,32 @@
local document_highlight = {}
vim.api.nvim_create_augroup('lsp_document_highlight', {
clear = false
})
function document_highlight.start(bufnr)
vim.api.nvim_clear_autocmds({
buffer = bufnr,
group = 'lsp_document_highlight',
})
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
group = 'lsp_document_highlight',
buffer = bufnr,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
group = 'lsp_document_highlight',
buffer = bufnr,
callback = vim.lsp.buf.clear_references,
})
end
function document_highlight.stop(bufnr)
vim.api.nvim_clear_autocmds({
buffer = bufnr,
group = 'lsp_document_highlight',
})
vim.lsp.buf.clear_references()
end
return document_highlight