fix: regression introduced in db78c0b217 (#1367)

pull/1368/head
Jonas Zeltner 3 weeks ago committed by GitHub
parent 7c49ba1cb7
commit e64aa51ef2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -558,13 +558,26 @@ require('lazy').setup({
-- For example, in C this would take you to the header.
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
---@param client vim.lsp.Client
---@param method vim.lsp.protocol.Method
---@param bufnr? integer some lsp support methods only in specific files
---@return boolean
local function client_supports_method(client, method, bufnr)
if vim.fn.has 'nvim-0.11' == 1 then
return client:supports_method(method, bufnr)
else
return client.supports_method(method, { bufnr = bufnr })
end
end
-- 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).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
@ -591,7 +604,7 @@ require('lazy').setup({
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints')

Loading…
Cancel
Save