@@ -85,6 +85,20 @@ function M.info(bufnr)
8585 require (" astrocore" ).notify (table.concat (lines , " \n " ), vim .log .levels .INFO , { title = " AstroNvim Folding" })
8686end
8787
88+ -- TODO: remove helper function when dropping support for Neovim v0.10
89+
90+ --- @param client vim.lsp.Client
91+ --- @param method string
92+ --- @param bufnr ? integer
93+ local function supports_method (client , method , bufnr )
94+ if vim .fn .has " nvim-0.11" == 1 then
95+ return client :supports_method (method , bufnr )
96+ else
97+ --- @diagnostic disable-next-line : param-type-mismatch
98+ return client .supports_method (method , { bufnr = bufnr })
99+ end
100+ end
101+
88102function M .setup ()
89103 vim .api .nvim_create_user_command (" AstroFoldInfo" , function () M .info () end , { desc = " Display folding information" })
90104 -- TODO: remove check when dropping support for Neovim v0.10
@@ -95,7 +109,7 @@ function M.setup()
95109 group = augroup ,
96110 callback = function (args )
97111 local client = assert (vim .lsp .get_client_by_id (args .data .client_id ))
98- if client . supports_method " textDocument/foldingRange" then lsp_bufs [args .buf ] = true end
112+ if supports_method ( client , " textDocument/foldingRange" , args . buf ) then lsp_bufs [args .buf ] = true end
99113 end ,
100114 })
101115 vim .api .nvim_create_autocmd (" LspDetach" , {
@@ -104,7 +118,9 @@ function M.setup()
104118 callback = function (args )
105119 if not vim .api .nvim_buf_is_valid (args .buf ) then return end
106120 for _ , client in pairs (vim .lsp .get_clients { bufnr = args .buf }) do
107- if client .id ~= args .data .client_id and client .supports_method " textDocument/foldingRange" then return end
121+ if client .id ~= args .data .client_id and supports_method (client , " textDocument/foldingRange" , args .buf ) then
122+ return
123+ end
108124 end
109125 lsp_bufs [args .buf ] = nil
110126 end ,
0 commit comments