diff options
| author | Jonas Zeltner <jonas.zeltner@posteo.de> | 2025-02-18 17:15:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-18 11:15:13 -0500 |
| commit | 81764ca05b47fdb13a38031ab326d8ef4bd1c93b (patch) | |
| tree | ef2de640f7cda9493dcdcef09fb79a3428dffb02 | |
| parent | 777fe6c5e2c840d13bb68b5562f9d815c54874d9 (diff) | |
| download | dots-81764ca05b47fdb13a38031ab326d8ef4bd1c93b.tar.gz | |
fix: regression introduced in df7b409dd2056d720cd2cd939f2dd74e310bf488 (#1367)
| -rw-r--r-- | nvim/init.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/nvim/init.lua b/nvim/init.lua index c8f2dc5..22ee9e4 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -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') |