@@ -562,13 +562,26 @@ require('lazy').setup({
562562 -- For example, in C this would take you to the header.
563563 map (' gD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
564564
565+ -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
566+ --- @param client vim.lsp.Client
567+ --- @param method vim.lsp.protocol.Method
568+ --- @param bufnr ? integer some lsp support methods only in specific files
569+ --- @return boolean
570+ local function client_supports_method (client , method , bufnr )
571+ if vim .fn .has ' nvim-0.11' == 1 then
572+ return client :supports_method (method , bufnr )
573+ else
574+ return client .supports_method (method , { bufnr = bufnr })
575+ end
576+ end
577+
565578 -- The following two autocommands are used to highlight references of the
566579 -- word under your cursor when your cursor rests there for a little while.
567580 -- See `:help CursorHold` for information about when this is executed
568581 --
569582 -- When you move your cursor, the highlights will be cleared (the second autocommand).
570583 local client = vim .lsp .get_client_by_id (event .data .client_id )
571- if client and client : supports_method ( vim .lsp .protocol .Methods .textDocument_documentHighlight ) then
584+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_documentHighlight , event . buf ) then
572585 local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
573586 vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
574587 buffer = event .buf ,
@@ -595,7 +608,7 @@ require('lazy').setup({
595608 -- code, if the language server you are using supports them
596609 --
597610 -- This may be unwanted, since they displace some of your code
598- if client and client : supports_method ( vim .lsp .protocol .Methods .textDocument_inlayHint ) then
611+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_inlayHint , event . buf ) then
599612 map (' <leader>th' , function ()
600613 vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
601614 end , ' [T]oggle Inlay [H]ints' )
0 commit comments