@@ -597,13 +597,26 @@ require('lazy').setup({
597597 -- For example, in C this would take you to the header.
598598 map (' gD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
599599
600+ -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
601+ --- @param client vim.lsp.Client
602+ --- @param method vim.lsp.protocol.Method
603+ --- @param bufnr ? integer some lsp support methods only in specific files
604+ --- @return boolean
605+ local function client_supports_method (client , method , bufnr )
606+ if vim .fn .has ' nvim-0.11' == 1 then
607+ return client :supports_method (method , bufnr )
608+ else
609+ return client .supports_method (method , { bufnr = bufnr })
610+ end
611+ end
612+
600613 -- The following two autocommands are used to highlight references of the
601614 -- word under your cursor when your cursor rests there for a little while.
602615 -- See `:help CursorHold` for information about when this is executed
603616 --
604617 -- When you move your cursor, the highlights will be cleared (the second autocommand).
605618 local client = vim .lsp .get_client_by_id (event .data .client_id )
606- if client and client : supports_method ( vim .lsp .protocol .Methods .textDocument_documentHighlight ) then
619+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_documentHighlight , event . buf ) then
607620 local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
608621 vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
609622 buffer = event .buf ,
@@ -630,7 +643,7 @@ require('lazy').setup({
630643 -- code, if the language server you are using supports them
631644 --
632645 -- This may be unwanted, since they displace some of your code
633- if client and client : supports_method ( vim .lsp .protocol .Methods .textDocument_inlayHint ) then
646+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_inlayHint , event . buf ) then
634647 map (' <leader>th' , function ()
635648 vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
636649 end , ' [T]oggle Inlay [H]ints' )
0 commit comments