Skip to content

Commit a284b14

Browse files
authored
refactor: move all old get_clients to new compatible (neovim#3159)
1 parent 39106f0 commit a284b14

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

Diff for: lua/lspconfig/server_configurations/basedpyright.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local function organize_imports()
1616
arguments = { vim.uri_from_bufnr(0) },
1717
}
1818

19-
local clients = vim.lsp.get_active_clients {
19+
local clients = util.get_lsp_clients {
2020
bufnr = vim.api.nvim_get_current_buf(),
2121
name = 'basedpyright',
2222
}
@@ -26,7 +26,7 @@ local function organize_imports()
2626
end
2727

2828
local function set_python_path(path)
29-
local clients = vim.lsp.get_active_clients {
29+
local clients = util.get_lsp_clients {
3030
bufnr = vim.api.nvim_get_current_buf(),
3131
name = 'basedpyright',
3232
}

Diff for: lua/lspconfig/server_configurations/denols.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ return {
9696
commands = {
9797
DenolsCache = {
9898
function()
99-
local clients = vim.lsp.get_active_clients { bufnr = 0, name = 'denols' }
99+
local clients = util.get_lsp_clients { bufnr = 0, name = 'denols' }
100100
if #clients > 0 then
101101
buf_cache(0, clients[#clients])
102102
end

Diff for: lua/lspconfig/server_configurations/gopls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ return {
1515
end
1616
end
1717
if fname:sub(1, #mod_cache) == mod_cache then
18-
local clients = vim.lsp.get_active_clients { name = 'gopls' }
18+
local clients = util.get_lsp_clients { name = 'gopls' }
1919
if #clients > 0 then
2020
return clients[#clients].config.root_dir
2121
end

Diff for: lua/lspconfig/server_configurations/pyright.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local function organize_imports()
1616
arguments = { vim.uri_from_bufnr(0) },
1717
}
1818

19-
local clients = vim.lsp.get_active_clients {
19+
local clients = util.get_lsp_clients {
2020
bufnr = vim.api.nvim_get_current_buf(),
2121
name = 'pyright',
2222
}
@@ -26,7 +26,7 @@ local function organize_imports()
2626
end
2727

2828
local function set_python_path(path)
29-
local clients = vim.lsp.get_active_clients {
29+
local clients = util.get_lsp_clients {
3030
bufnr = vim.api.nvim_get_current_buf(),
3131
name = 'pyright',
3232
}

Diff for: lua/lspconfig/server_configurations/rust_analyzer.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local async = require 'lspconfig.async'
33

44
local function reload_workspace(bufnr)
55
bufnr = util.validate_bufnr(bufnr)
6-
local clients = vim.lsp.get_active_clients { name = 'rust_analyzer', bufnr = bufnr }
6+
local clients = util.get_lsp_clients { bufnr = bufnr, name = 'rust_analyzer' }
77
for _, client in ipairs(clients) do
88
vim.notify 'Reloading Cargo Workspace'
99
client.request('rust-analyzer/reloadWorkspace', nil, function(err)
@@ -26,7 +26,7 @@ local function is_library(fname)
2626

2727
for _, item in ipairs { toolchains, registry, git_registry } do
2828
if util.path.is_descendant(item, fname) then
29-
local clients = vim.lsp.get_active_clients { name = 'rust_analyzer' }
29+
local clients = util.get_lsp_clients { name = 'rust_analyzer' }
3030
return #clients > 0 and clients[#clients].config.root_dir or nil
3131
end
3232
end

Diff for: lua/lspconfig/ui/lspinfo.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local api, fn, lsp = vim.api, vim.fn, vim.lsp
1+
local api, fn = vim.api, vim.fn
22
local windows = require 'lspconfig.ui.windows'
33
local util = require 'lspconfig.util'
44

@@ -188,8 +188,8 @@ return function()
188188
-- These options need to be cached before switching to the floating
189189
-- buffer.
190190
local original_bufnr = api.nvim_get_current_buf()
191-
local buf_clients = lsp.get_active_clients { bufnr = original_bufnr }
192-
local clients = lsp.get_active_clients()
191+
local buf_clients = util.get_lsp_clients { bufnr = original_bufnr }
192+
local clients = util.get_lsp_clients()
193193
local buffer_filetype = vim.bo.filetype
194194
local fname = api.nvim_buf_get_name(original_bufnr)
195195

Diff for: lua/lspconfig/util.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ function M.tbl_flatten(t)
266266
return nvim_ten and vim.iter(t):flatten(math.huge):totable() or vim.tbl_flatten(t)
267267
end
268268

269-
local function get_lsp_clients(filter)
269+
function M.get_lsp_clients(filter)
270270
return nvim_ten and lsp.get_clients(filter) or lsp.get_active_clients(filter)
271271
end
272272

@@ -342,7 +342,7 @@ function M.insert_package_json(config_files, field, fname)
342342
end
343343

344344
function M.get_active_clients_list_by_ft(filetype)
345-
local clients = get_lsp_clients()
345+
local clients = M.get_lsp_clients()
346346
local clients_list = {}
347347
for _, client in pairs(clients) do
348348
local filetypes = client.config.filetypes or {}
@@ -388,7 +388,7 @@ end
388388

389389
function M.get_active_client_by_name(bufnr, servername)
390390
--TODO(glepnir): remove this for loop when we want only support 0.10+
391-
for _, client in pairs(get_lsp_clients { bufnr = bufnr }) do
391+
for _, client in pairs(M.get_lsp_clients { bufnr = bufnr }) do
392392
if client.name == servername then
393393
return client
394394
end

Diff for: plugin/lspconfig.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ api.nvim_create_user_command('LspStop', function(info)
135135
end
136136

137137
if not server_id then
138-
local servers_on_buffer = lsp.get_active_clients { bufnr = current_buf }
138+
local servers_on_buffer = require('lspconfig.util').get_lsp_clients { bufnr = current_buf }
139139
for _, client in ipairs(servers_on_buffer) do
140140
if client.attached_buffers[current_buf] then
141141
client.stop(force)

0 commit comments

Comments
 (0)