From f0687cbae51b526265f717c5928126f268dd7210 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Thu, 14 Nov 2024 13:15:21 +0000 Subject: [PATCH] fix calls to deprecated API from neovim 0.12 onwards, `vim.lsp.get_active_clients()` is deprecated. This commit replaces the corresponding calls by ones to the updated API. fixes #16 --- lua/ltex-utils/diagnostics.lua | 2 +- lua/ltex-utils/ltex_lsp.lua | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/ltex-utils/diagnostics.lua b/lua/ltex-utils/diagnostics.lua index 4aad1c3..c995a42 100644 --- a/lua/ltex-utils/diagnostics.lua +++ b/lua/ltex-utils/diagnostics.lua @@ -7,7 +7,7 @@ local M = {} function M.get_ltex_namespace(bufnr) ---@type integer local id - for _, client in ipairs(vim.lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in ipairs(vim.lsp.get_clients({ bufnr = bufnr })) do if client.name == "ltex" then id = client.id break diff --git a/lua/ltex-utils/ltex_lsp.lua b/lua/ltex-utils/ltex_lsp.lua index 3e05104..fc34b2c 100644 --- a/lua/ltex-utils/ltex_lsp.lua +++ b/lua/ltex-utils/ltex_lsp.lua @@ -12,12 +12,14 @@ local M = {} ---Returns the first active LTeX LSP client attached to a buffer. ---NOTE: vim.lsp.buf_get_clients() is deprecated; ---use vim.lsp.get_active_clients instead. +---NOTE: vim.lsp.get_active_clients is deprecated form nvim 0.12; +---use vim.lsp.get_clients instead. ---@param bufnr integer|nil Buffer number; if not provided uses current buffer. ---@return table|nil # LTeX LSP client if found, otherwise nil. function M.get_ltex(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() - for _, client in ipairs(vim.lsp.get_active_clients({ buffer = bufnr })) do + for _, client in ipairs(vim.lsp.get_clients({ bufnr = bufnr })) do if client.name == 'ltex' then return client end