From 6f27462fc5022c5d64e3ff21ed9aff5b7b653d97 Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Mon, 20 May 2024 21:04:46 +0300 Subject: [PATCH] refactor!: remove lsp_util (nvim 0.9.0 compatibility) BREAKING CHANGE: This commit removes the `lsp_util` module, which was used to provide compatibility with Neovim 0.9.0. We now only support nvim 0.10.0 and later. This was announced before, but I forgot to use `!` in the commit message. This is probably the first breaking change for nvim 0.9.0. --- lua/yazi/lsp/delete.lua | 12 ++++++++---- lua/yazi/lsp/lsp_util.lua | 15 --------------- lua/yazi/lsp/rename.lua | 12 ++++++++---- 3 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 lua/yazi/lsp/lsp_util.lua diff --git a/lua/yazi/lsp/delete.lua b/lua/yazi/lsp/delete.lua index c0c08fc8..b15bc886 100644 --- a/lua/yazi/lsp/delete.lua +++ b/lua/yazi/lsp/delete.lua @@ -1,5 +1,3 @@ -local lsp_util = require('yazi.lsp.lsp_util') - local M = {} ---@param path string @@ -7,7 +5,10 @@ local function notify_file_was_deleted(path) -- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_willDeleteFiles local method = 'workspace/willDeleteFiles' - local clients = lsp_util.get_clients(method, vim.api.nvim_get_current_buf()) + local clients = vim.lsp.get_clients({ + method = method, + bufnr = vim.api.nvim_get_current_buf(), + }) for _, client in ipairs(clients) do local resp = client.request_sync(method, { @@ -29,7 +30,10 @@ local function notify_delete_complete(path) -- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didDeleteFiles local method = 'workspace/didDeleteFiles' - local clients = lsp_util.get_clients(method, vim.api.nvim_get_current_buf()) + local clients = vim.lsp.get_clients({ + method = method, + bufnr = vim.api.nvim_get_current_buf(), + }) for _, client in ipairs(clients) do -- NOTE: this returns nothing, so no need to do anything with the response diff --git a/lua/yazi/lsp/lsp_util.lua b/lua/yazi/lsp/lsp_util.lua deleted file mode 100644 index b3f0d442..00000000 --- a/lua/yazi/lsp/lsp_util.lua +++ /dev/null @@ -1,15 +0,0 @@ -local M = {} - --- For nvim 0.9 compatibility ----@param lsp_method string -function M.get_clients(lsp_method) - -- TODO remove this when we drop support for nvim 0.9 - - ---@diagnostic disable-next-line: deprecated - but needed for compatibility - local clients = vim.lsp.get_active_clients() - return vim.tbl_filter(function(client) - return client.supports_method(lsp_method) - end, clients) -end - -return M diff --git a/lua/yazi/lsp/rename.lua b/lua/yazi/lsp/rename.lua index 50cf7104..ac05ade5 100644 --- a/lua/yazi/lsp/rename.lua +++ b/lua/yazi/lsp/rename.lua @@ -1,5 +1,3 @@ -local lsp_util = require('yazi.lsp.lsp_util') - local M = {} ---@param from string @@ -8,7 +6,10 @@ local function notify_file_was_renamed(from, to) -- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_willRenameFiles local method = 'workspace/willRenameFiles' - local clients = lsp_util.get_clients(method) + local clients = vim.lsp.get_clients({ + method = method, + bufnr = vim.api.nvim_get_current_buf(), + }) for _, client in ipairs(clients) do local resp = client.request_sync(method, { @@ -32,7 +33,10 @@ local function notify_rename_complete(from, to) -- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didRenameFiles local method = 'workspace/didRenameFiles' - local clients = lsp_util.get_clients(method) + local clients = vim.lsp.get_clients({ + method = method, + bufnr = vim.api.nvim_get_current_buf(), + }) for _, client in ipairs(clients) do -- NOTE: this returns nothing, so no need to do anything with the response