Skip to content

Commit

Permalink
fix: textDocument/documentHighlight
Browse files Browse the repository at this point in the history
  • Loading branch information
willruggiano committed Feb 26, 2024
1 parent 1473996 commit bad72f0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ return function()
client.config.flags.allow_incremental_sync = true
end

local lsp_codelens = vim.api.nvim_create_augroup("LspCodelens", {})

local keymap = require "bombadil.lib.keymap"

-- Use an on_attach function to only map the following keys
Expand Down Expand Up @@ -185,20 +183,26 @@ return function()
},
}

vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
callback = vim.lsp.buf.clear_references,
})
if client.supports_method "textDocument/documentHighlight" then
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = bufnr,
callback = vim.lsp.buf.document_highlight,
once = true,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = bufnr,
callback = vim.lsp.buf.clear_references,
once = true,
})
end

if client.supports_method "textDocument/codeLens" then
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, {
group = lsp_codelens,
buffer = bufnr,
callback = function()
vim.lsp.codelens.refresh()
end,
once = true,
})
end
end
Expand Down

0 comments on commit bad72f0

Please sign in to comment.