nvim: lsp: Minor clean up of autocmd callbacks

This commit is contained in:
Sanchayan Maity 2022-09-09 17:06:19 +05:30
parent 108403ca3d
commit b398542a94

View file

@ -152,35 +152,27 @@ local on_attach = function(client, bufnr)
if client.server_capabilities.codeLensProvider then if client.server_capabilities.codeLensProvider then
vim.api.nvim_buf_set_keymap(bufnr, "n", "<Leader>l", "<cmd>lua vim.lsp.codelens.run()<CR>", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "<Leader>l", "<cmd>lua vim.lsp.codelens.run()<CR>", opts)
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI", "InsertLeave"}, { vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI", "InsertLeave"}, {
group = lsp_augroup_id, group = lsp_augroup_id,
buffer = bufnr, buffer = bufnr,
callback = function () callback = vim.lsp.codelens.refresh,
vim.lsp.codelens.refresh()
end,
}) })
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI"}, { vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI"}, {
group = lsp_augroup_id, group = lsp_augroup_id,
buffer = bufnr, buffer = bufnr,
callback = function () callback = lightbulb.update_lightbulb,
lightbulb.update_lightbulb()
end,
}) })
end end
if client.server_capabilities.documentHighlightProvider then if client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd("CursorHold", { vim.api.nvim_create_autocmd("CursorHold", {
group = lsp_augroup_id, group = lsp_augroup_id,
buffer = bufnr, buffer = bufnr,
callback = function () callback = vim.lsp.buf.document_highlight,
vim.lsp.buf.document_highlight()
end,
}) })
vim.api.nvim_create_autocmd("CursorMoved", { vim.api.nvim_create_autocmd("CursorMoved", {
group = lsp_augroup_id, group = lsp_augroup_id,
buffer = bufnr, buffer = bufnr,
callback = function () callback = vim.lsp.buf.clear_references,
vim.lsp.buf.clear_references()
end,
}) })
end end
end end