Skip to content

Commit 0092e4b

Browse files
authored
Merge branch 'nvim-lua:master' into master
2 parents 2c5d8e8 + 8df3deb commit 0092e4b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ That's it! Lazy will install all the plugins you have. Use `:Lazy` to view
9999
current plugin status. Hit `q` to close the window.
100100

101101
Read through the `init.lua` file in your configuration folder for more
102-
information about extending and exploring Neovim. That includes also
102+
information about extending and exploring Neovim. That also includes
103103
examples of adding popularly requested plugins.
104104

105105

init.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,16 @@ require('lazy').setup({
518518
-- When you move your cursor, the highlights will be cleared (the second autocommand).
519519
local client = vim.lsp.get_client_by_id(event.data.client_id)
520520
if client and client.server_capabilities.documentHighlightProvider then
521+
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
521522
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
522523
buffer = event.buf,
524+
group = highlight_augroup,
523525
callback = vim.lsp.buf.document_highlight,
524526
})
525527

526528
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
527529
buffer = event.buf,
530+
group = highlight_augroup,
528531
callback = vim.lsp.buf.clear_references,
529532
})
530533
end
@@ -535,12 +538,20 @@ require('lazy').setup({
535538
-- This may be unwanted, since they displace some of your code
536539
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
537540
map('<leader>th', function()
538-
vim.lsp.inlay_hint.enable(0, not vim.lsp.inlay_hint.is_enabled())
541+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
539542
end, '[T]oggle Inlay [H]ints')
540543
end
541544
end,
542545
})
543546

547+
vim.api.nvim_create_autocmd('LspDetach', {
548+
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
549+
callback = function(event)
550+
vim.lsp.buf.clear_references()
551+
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf }
552+
end,
553+
})
554+
544555
-- LSP servers and clients are able to communicate to each other what features they support.
545556
-- By default, Neovim doesn't support everything that is in the LSP specification.
546557
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.

0 commit comments

Comments
 (0)