diff --git a/lua/navigator/cclshierarchy.lua b/lua/navigator/cclshierarchy.lua index 5dbc94f..e408991 100644 --- a/lua/navigator/cclshierarchy.lua +++ b/lua/navigator/cclshierarchy.lua @@ -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 diff --git a/lua/navigator/codelens.lua b/lua/navigator/codelens.lua index 950a218..9dfdbea 100644 --- a/lua/navigator/codelens.lua +++ b/lua/navigator/codelens.lua @@ -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 diff --git a/lua/navigator/definition.lua b/lua/navigator/definition.lua index f3692b8..83924b9 100644 --- a/lua/navigator/definition.lua +++ b/lua/navigator/definition.lua @@ -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) diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index 5d09682..771042d 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -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 diff --git a/lua/navigator/foldlsp.lua b/lua/navigator/foldlsp.lua index c23da43..6111199 100644 --- a/lua/navigator/foldlsp.lua +++ b/lua/navigator/foldlsp.lua @@ -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? diff --git a/lua/navigator/hierarchy.lua b/lua/navigator/hierarchy.lua index 51c9902..d9bc29e 100644 --- a/lua/navigator/hierarchy.lua +++ b/lua/navigator/hierarchy.lua @@ -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') diff --git a/lua/navigator/lspclient/clients.lua b/lua/navigator/lspclient/clients.lua index 4259ccd..482dff5 100644 --- a/lua/navigator/lspclient/clients.lua +++ b/lua/navigator/lspclient/clients.lua @@ -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 diff --git a/lua/navigator/lspclient/mapping.lua b/lua/navigator/lspclient/mapping.lua index 7eb2a43..548ef6b 100644 --- a/lua/navigator/lspclient/mapping.lua +++ b/lua/navigator/lspclient/mapping.lua @@ -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 diff --git a/lua/navigator/lspwrapper.lua b/lua/navigator/lspwrapper.lua index 0a3cdbb..c5dead0 100644 --- a/lua/navigator/lspwrapper.lua +++ b/lua/navigator/lspwrapper.lua @@ -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