aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config
diff options
context:
space:
mode:
Diffstat (limited to 'home/.config')
-rw-r--r--home/.config/nvim/lua/custom/plugins/lsp.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/home/.config/nvim/lua/custom/plugins/lsp.lua b/home/.config/nvim/lua/custom/plugins/lsp.lua
index 6bd73d7..ad7d43d 100644
--- a/home/.config/nvim/lua/custom/plugins/lsp.lua
+++ b/home/.config/nvim/lua/custom/plugins/lsp.lua
@@ -119,6 +119,45 @@ return {
map.n("gR", vim.lsp.buf.rename, { buffer = bufnr })
map.n("ga", vim.lsp.buf.code_action, { buffer = bufnr })
map.v("ga", vim.lsp.buf.code_action, { buffer = bufnr })
+
+ -- The following two autocommands are used to highlight references of the
+ -- word under your cursor when your cursor rests there for a little while.
+ -- See `:help CursorHold` for information about when this is executed
+ --
+ -- When you move your cursor, the highlights will be cleared (the second autocommand).
+ if client.server_capabilities.documentHighlightProvider then
+ local highlight_augroup = vim.api.nvim_create_augroup('lsp-highlight', { clear = false })
+ vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
+ buffer = bufnr,
+ group = highlight_augroup,
+ callback = vim.lsp.buf.document_highlight,
+ })
+
+ vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
+ buffer = bufnr,
+ group = highlight_augroup,
+ callback = vim.lsp.buf.clear_references,
+ })
+
+ vim.api.nvim_create_autocmd('LspDetach', {
+ group = vim.api.nvim_create_augroup('lsp-detach', { clear = true }),
+ callback = function(event2)
+ vim.lsp.buf.clear_references()
+ vim.api.nvim_clear_autocmds { group = 'lsp-highlight', buffer = event2.buf }
+ end,
+ })
+ end
+
+ -- The following autocommand is used to enable inlay hints in your
+ -- code, if the language server you are using supports them
+ --
+ -- This may be unwanted, since they displace some of your code
+ if client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
+ map.n('<leader>th', function()
+ vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({}))
+ vim.lsp.inlay_hint.enable()
+ end, { buffer = bufnr })
+ end
end,
})
end,