From 1f941b3668151963fca3e1230922c433ea4b7b64 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:04:47 +0100 Subject: revert: "refactor!: make available_servers function private" #3589 This reverts commit e118ce58dab72c17216292eef7df4cee3cf60885. It turns out `util.available_servers` is used more than anticipated, so we revert the privatization for the time being. Closes https://github.com/neovim/nvim-lspconfig/issues/3588 --- lua/lspconfig/health.lua | 2 +- lua/lspconfig/util.lua | 3 ++- plugin/lspconfig.lua | 2 +- test/lspconfig_spec.lua | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/lspconfig/health.lua b/lua/lspconfig/health.lua index c88d786d..64c584cf 100644 --- a/lua/lspconfig/health.lua +++ b/lua/lspconfig/health.lua @@ -224,7 +224,7 @@ local function check_lspconfig(bufnr) bufnr = (bufnr and bufnr ~= -1) and bufnr or nil health.start('LSP configs active in this session (globally)') - health.info('Configured servers: ' .. table.concat(util._available_servers(), ', ')) + health.info('Configured servers: ' .. table.concat(util.available_servers(), ', ')) local deprecated_servers = {} for server_name, deprecate in pairs(require('lspconfig').server_aliases()) do table.insert(deprecated_servers, ('%s -> %s'):format(server_name, deprecate.to)) diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index bfcbb0a6..ae891010 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -223,7 +223,8 @@ function M.get_managed_clients() return clients end -function M._available_servers() +--- @deprecated use `vim.lsp.config` in Nvim 0.11+ instead. +function M.available_servers() local servers = {} local configs = require 'lspconfig.configs' for server, config in pairs(configs) do diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index 44a1fcf9..92a8208b 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -14,7 +14,7 @@ end local lsp_complete_configured_servers = function(arg) return completion_sort(vim.tbl_filter(function(s) return s:sub(1, #arg) == arg - end, util._available_servers())) + end, util.available_servers())) end local lsp_get_active_clients = function(arg) diff --git a/test/lspconfig_spec.lua b/test/lspconfig_spec.lua index 39e5783a..52d33eac 100644 --- a/test/lspconfig_spec.lua +++ b/test/lspconfig_spec.lua @@ -144,7 +144,7 @@ describe('lspconfig', function() local _ = lspconfig.lua_ls local _ = lspconfig.tsserver lspconfig.rust_analyzer.setup {} - same({ 'rust_analyzer' }, require('lspconfig.util')._available_servers()) + same({ 'rust_analyzer' }, require('lspconfig.util').available_servers()) end) it('provides user_config to the on_setup hook', function() -- cgit v1.2.3-70-g09d2