deprecate lsp.buf_get_clients

pull/244/head
ray-x 2 years ago
parent 544c006a10
commit ce81b4a6da

@ -13,7 +13,7 @@ local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_me
log('call_hierarchy')
log('call_hierarchy', direction, err, result, ctx, cfg)
assert(next(vim.lsp.buf_get_clients()), 'Must have a client running to use lsp_tags')
assert(next(vim.lsp.get_active_clients()), 'Must have a client running to use lsp_tags')
if err ~= nil then
log('hierarchy error', ctx, 'dir', direction, 'result', result, 'err', err)
vim.notify('ERROR: ' .. error_message, vim.lsp.log_levels.WARN)
@ -53,7 +53,7 @@ local call_hierarchy_handler_to = partial(call_hierarchy_handler, 'to')
local function incoming_calls_handler(_, err, result, ctx, cfg)
local bufnr = vim.api.nvim_get_current_buf()
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use lsp_tags')
assert(next(vim.lsp.get_active_clients({buffer = bufnr})), 'Must have a client running to use lsp_tags' )
local results = call_hierarchy_handler_from(err, result, ctx, cfg, 'Incoming calls not found')
@ -71,7 +71,7 @@ end
function M.incoming_calls(bang, opts)
local bufnr = vim.api.nvim_get_current_buf()
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use lsp_tags')
assert(next(vim.lsp.get_active_clients({buffer = bufnr})), 'Must have a client running to use lsp_tags' )
-- if not lsphelper.check_capabilities("call_hierarchy") then
-- return
-- end
@ -88,7 +88,7 @@ end
function M.outgoing_calls(bang, opts)
local bufnr = vim.api.nvim_get_current_buf()
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use lsp_tags')
assert(next(vim.lsp.get_active_clients({buffer = bufnr})), 'Must have a client running to use lsp_tags')
local params = vim.lsp.util.make_position_params()
params['levels'] = 2
params['callee'] = true

@ -79,7 +79,7 @@ end
M.lsp_clients = {}
function M.refresh()
if next(vim.lsp.buf_get_clients(0)) == nil then
if next(vim.lsp.get_active_clients({ buffer = 0 })) == nil then
log('Must have a client running to use lsp code action')
return
end
@ -119,7 +119,7 @@ M.inline = function()
return
end
if next(vim.lsp.buf_get_clients(0)) == nil then
if next(vim.lsp.get_active_clients({buffer = 0})) == nil then
return
end

@ -44,7 +44,7 @@ local function get_symbol()
end
local function def_preview(timeout_ms)
assert(next(vim.lsp.buf_get_clients(0)), 'Must have a client running')
assert(next(vim.lsp.get_active_clients({buffer = 0})), 'Must have a client running')
local method = 'textDocument/definition'
local params = vim.lsp.util.make_position_params()
local result = vim.lsp.buf_request_sync(0, method, params, timeout_ms or 1000)

@ -409,14 +409,14 @@ M.set_diag_loclist = function(bufnr)
return
end
local clients = vim.lsp.buf_get_clients(bufnr)
local clients = vim.lsp.get_active_clients({buffer = bufnr })
local cfg = { open = diag_cnt > 0 }
for _, client in pairs(clients) do
cfg.client_id = client['id']
break
end
if not vim.tbl_isempty(vim.lsp.buf_get_clients(bufnr)) then
if not vim.tbl_isempty(vim.lsp.get_active_clients({buffer = bufnr})) then
local err_cnt = get_count(0, [[Error]])
if err_cnt > 0 and _NgConfigValues.lsp.disply_diagnostic_qf then
if diagnostic.set_loclist then

@ -37,7 +37,7 @@ function M.setup_plugin()
end,
})
local clients = vim.lsp.buf_get_clients(0)
local clients = vim.lsp.get_active_clients({buffer = 0})
for _, client in pairs(clients) do
local client_id = client['id']
@ -60,7 +60,7 @@ function M.update_folds()
-- In diff mode, use diff folding.
api.nvim_win_set_option(current_window, 'foldmethod', 'diff')
else
local clients = lsp.buf_get_clients(0)
local clients = lsp.get_active_clients({buffer = 0})
for client_id, client in pairs(clients) do
if M.active_folding_clients[client_id] then
-- XXX: better to pass callback in this method or add it directly in the config?

@ -52,7 +52,7 @@ local function call_hierarchy_result_procesor(direction, err, result, ctx, confi
-- trace('call_hierarchy', result)
local bufnr = ctx.bufnr or vim.api.nvim_get_current_buf()
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use call hierarchy')
assert(next(vim.lsp.get_active_clients({buffer = bufnr})), 'Must have a client running to use call hierarchy')
if err ~= nil then
log('dir', direction, 'result', result, 'err', err, ctx)
vim.notify('ERROR: ' .. err, vim.lsp.log_levels.WARN)
@ -103,7 +103,7 @@ hierarchy_handler = function(dir, handler, show, api, err, result, ctx, cfg)
local opts = ctx.opts or {}
vim.validate({ handler = { handler, 'function' }, show = { show, 'function' }, api = { api, 'string' } })
local bufnr = ctx.bufnr or vim.api.nvim_get_current_buf()
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use lsp hierarchy')
assert(next(vim.lsp.get_active_clients({buffer = bufnr})), 'Must have a client running to use lsp hierarchy')
local results = handler(err, result, ctx, cfg, 'Incoming calls not found')

@ -145,7 +145,7 @@ local function load_cfg(ft, client, cfg, loaded, starting)
end
end
local clients = vim.lsp.buf_get_clients(0)
local clients = vim.lsp.get_active_clients({buffer = 0 })
for _, c in pairs(clients or {}) do
log("lsp start up in progress client", client, c.name)
if c.name == client then
@ -588,7 +588,7 @@ local function setup(user_opts, cnt)
trace(debug.traceback())
local clients = vim.lsp.buf_get_clients(bufnr)
local clients = vim.lsp.get_active_clients({buffer = bufnr})
for key, client in pairs(clients) do
if client.name ~= 'null_ls' and client.name ~= 'efm' then
if vim.tbl_contains(client.filetypes or {}, vim.o.ft) then

@ -81,7 +81,7 @@ local ccls_mappings = {
}
local check_cap = function(opts)
-- log(vim.lsp.buf_get_clients(0))
-- log(vim.lsp.get_active_clients({buffer = 0}))
local fmt, rfmt, ccls
local cap = opts.cap
if cap == nil then
@ -95,7 +95,7 @@ local check_cap = function(opts)
if cap and cap.documentRangeFormattingProvider then
rfmt = true
end
for _, value in pairs(vim.lsp.buf_get_clients(0)) do
for _, value in pairs(vim.lsp.get_active_clients({buffer = 0})) do
trace(value)
if value ~= nil and value.server_capabilities == nil then
if value.server_capabilities.documentFormattingProvider then

@ -119,7 +119,7 @@ local function extract_result(results_lsp)
end
function M.check_capabilities(feature, client_id)
local clients = lsp.buf_get_clients(client_id or 0)
local clients = lsp.get_active_clients({buffer = client_id or 0 })
local supported_client = false
for _, client in pairs(clients) do

Loading…
Cancel
Save