diff --git a/lua/navigator/codelens.lua b/lua/navigator/codelens.lua index 994f297..41a79c9 100644 --- a/lua/navigator/codelens.lua +++ b/lua/navigator/codelens.lua @@ -96,7 +96,7 @@ function M.refresh() log('Must have a client running to use lsp code action') return end - if not lsphelper.check_capabilities('code_lens') then + if not lsphelper.check_capabilities('codeLensProvider') then return end vim.lsp.codelens.refresh() diff --git a/lua/navigator/definition.lua b/lua/navigator/definition.lua index b491dd6..d02dc0c 100644 --- a/lua/navigator/definition.lua +++ b/lua/navigator/definition.lua @@ -144,7 +144,8 @@ local def = function() local ref_params = vim.lsp.util.make_position_params() vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, _bufnr) - if client.resolved_capabilities.goto_definition then + -- if client.resolved_capabilities.goto_definition then + if client.server_capabilities.definitionProvider then client.request('textDocument/definition', ref_params, definition_hdlr, _bufnr) end end) diff --git a/lua/navigator/dochighlight.lua b/lua/navigator/dochighlight.lua index 742c183..1b97f01 100644 --- a/lua/navigator/dochighlight.lua +++ b/lua/navigator/dochighlight.lua @@ -210,7 +210,7 @@ _G.nav_doc_hl = function() local bufnr = vim.api.nvim_get_current_buf() local ref_params = vim.lsp.util.make_position_params() vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, bufnr) - if client.resolved_capabilities.document_highlight then + if client.server_capabilities.documentHighlightProvider then client.request('textDocument/documentHighlight', ref_params, handle_document_highlight, bufnr) end end) diff --git a/lua/navigator/hierarchy.lua b/lua/navigator/hierarchy.lua index 36badd5..5e80118 100644 --- a/lua/navigator/hierarchy.lua +++ b/lua/navigator/hierarchy.lua @@ -79,7 +79,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 hierarchy') - if not lsphelper.check_capabilities('call_hierarchy') then + if not lsphelper.check_capabilities('callHierarchyProvider') then return end @@ -90,7 +90,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') - if not lsphelper.check_capabilities('call_hierarchy') then + if not lsphelper.check_capabilities('callHierarchyProvider') then return end diff --git a/lua/navigator/implementation.lua b/lua/navigator/implementation.lua index 6096e60..208641d 100644 --- a/lua/navigator/implementation.lua +++ b/lua/navigator/implementation.lua @@ -23,7 +23,7 @@ local function implementation_handler(bang, err, result, ctx, cfg) end function M.implementation(bang, opts) - if not lsphelper.check_capabilities('implementation') then + if not lsphelper.check_capabilities('implementationProvider') then return end diff --git a/lua/navigator/lspclient/attach.lua b/lua/navigator/lspclient/attach.lua index 19dd8d3..3be7800 100644 --- a/lua/navigator/lspclient/attach.lua +++ b/lua/navigator/lspclient/attach.lua @@ -34,7 +34,7 @@ M.on_attach = function(client, bufnr) bufnr = bufnr, }) - if client.resolved_capabilities.document_highlight then + if client.server_capabilities.documentHighlightProvider then require('navigator.dochighlight').documentHighlight() end @@ -60,8 +60,8 @@ M.on_attach = function(client, bufnr) end if _NgConfigValues.lsp.code_action.enable then - if client.resolved_capabilities.code_action then - log('code action enabled for client', client.resolved_capabilities.code_action) + if client.server_capabilities.codeActionProvider then + log('code action enabled for client', client.server_capabilities.codeActionProvider) vim.cmd([[autocmd CursorHold,CursorHoldI lua require'navigator.codeAction'.code_action_prompt()]]) end end diff --git a/lua/navigator/lspclient/clients.lua b/lua/navigator/lspclient/clients.lua index a333bd1..1da0f52 100644 --- a/lua/navigator/lspclient/clients.lua +++ b/lua/navigator/lspclient/clients.lua @@ -184,8 +184,8 @@ local setups = { '--cross-file-rename', }, filetypes = { 'c', 'cpp', 'objc', 'objcpp' }, - on_attach = function(client, buffnr) - client.resolved_capabilities.document_formatting = true + on_attach = function(client, bufnr) + client.server_capabilities.documentFormattingProvider = true on_attach(client, bufnr) end, }, @@ -208,7 +208,7 @@ local setups = { sqls = { filetypes = { 'sql' }, on_attach = function(client, bufnr) - client.resolved_capabilities.execute_command = true + client.server_capabilities.executeCommandProvider = true highlight.diagnositc_config_sign() require('sqls').setup({ picker = 'telescope' }) -- or default end, @@ -546,7 +546,7 @@ local function lsp_startup(ft, retry, user_lsp_opts) if config.combined_attach == nil then cfg.on_attach = function(client, bufnr) on_attach(client, bufnr) - client.resolved_capabilities.document_formatting = enable_fmt + client.server_capabilities.documentFormattingProvider = enable_fmt end end if config.combined_attach == 'mine' then @@ -555,7 +555,7 @@ local function lsp_startup(ft, retry, user_lsp_opts) end cfg.on_attach = function(client, bufnr) config.on_attach(client, bufnr) - client.resolved_capabilities.document_formatting = enable_fmt + client.server_capabilities.documentFormattingProvider = enable_fmt require('navigator.lspclient.mapping').setup({ client = client, bufnr = bufnr, @@ -567,7 +567,7 @@ local function lsp_startup(ft, retry, user_lsp_opts) cfg.on_attach = function(client, bufnr) on_attach(client, bufnr) config.on_attach(client, bufnr) - client.resolved_capabilities.document_formatting = enable_fmt + client.server_capabilities.documentFormattingProvider = enable_fmt require('navigator.lspclient.mapping').setup({ client = client, bufnr = bufnr, @@ -577,7 +577,7 @@ local function lsp_startup(ft, retry, user_lsp_opts) end if config.combined_attach == 'both' then cfg.on_attach = function(client, bufnr) - client.resolved_capabilities.document_formatting = enable_fmt + client.server_capabilities.documentFormattingProvider = enable_fmt if config.on_attach and type(config.on_attach) == 'function' then config.on_attach(client, bufnr) end @@ -605,7 +605,7 @@ local function lsp_startup(ft, retry, user_lsp_opts) else cfg.on_attach = function(client, bufnr) on_attach(client, bufnr) - client.resolved_capabilities.document_formatting = enable_fmt + client.server_capabilities.documentFormattingProvider = enable_fmt end end diff --git a/lua/navigator/lspclient/mapping.lua b/lua/navigator/lspclient/mapping.lua index 6cc650b..95c9709 100644 --- a/lua/navigator/lspclient/mapping.lua +++ b/lua/navigator/lspclient/mapping.lua @@ -71,23 +71,23 @@ local check_cap = function(opts) local fmt, rfmt, ccls local cap = opts.cap if cap == nil then - if opts.client and opts.client.resolved_capabilities then - cap = opts.client.resolved_capabilities + if opts.client and opts.client.server_capabilities then + cap = opts.client.server_capabilities end end - if cap and cap.document_formatting then + if cap and cap.documentFormattingProvider then fmt = true end - if cap and cap.document_range_formatting then + if cap and cap.documentRangeFormattingProvider then rfmt = true end for _, value in pairs(vim.lsp.buf_get_clients(0)) do trace(value) - if value ~= nil and value.resolved_capabilities == nil then - if value.resolved_capabilities.document_formatting then + if value ~= nil and value.server_capabilities == nil then + if value.server_capabilities.documentFormattingProvider then fmt = true end - if value.resolved_capabilities.document_range_formatting then + if value.server_capabilities.documentRangeFormattingProvider then rfmt = true end @@ -257,11 +257,11 @@ function M.setup(user_opts) set_event_handler(user_opts) local client = user_opts.client or {} - local cap = client.resolved_capabilities or vim.lsp.protocol.make_client_capabilities() + local cap = client.server_capabilities or vim.lsp.protocol.make_client_capabilities() log('lsp cap:', cap) - if cap.call_hierarchy or cap.callHierarchy then + if cap.call_hierarchy or cap.callHierarchyProvider then vim.lsp.handlers['callHierarchy/incomingCalls'] = require('navigator.hierarchy').incoming_calls_handler vim.lsp.handlers['callHierarchy/outgoingCalls'] = require('navigator.hierarchy').outgoing_calls_handler end @@ -270,7 +270,7 @@ function M.setup(user_opts) -- vim.lsp.handlers["textDocument/codeAction"] = require"navigator.codeAction".code_action_handler vim.lsp.handlers['textDocument/definition'] = require('navigator.definition').definition_handler - if cap.declaration then + if cap.declarationProvider then vim.lsp.handlers['textDocument/declaration'] = require('navigator.definition').declaration_handler end @@ -298,7 +298,7 @@ function M.setup(user_opts) end vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = single }) - if cap.document_formatting then + if cap.documentFormattingProvider then log('formatting enabled setup hdl') vim.lsp.handlers['textDocument/formatting'] = require('navigator.formatting').format_hdl end diff --git a/lua/navigator/lspwrapper.lua b/lua/navigator/lspwrapper.lua index 143e03a..c1164b8 100644 --- a/lua/navigator/lspwrapper.lua +++ b/lua/navigator/lspwrapper.lua @@ -122,7 +122,8 @@ function M.check_capabilities(feature, client_id) local supported_client = false for _, client in pairs(clients) do - supported_client = client.resolved_capabilities[feature] + -- supported_client = client.resolved_capabilities[feature] + supported_client = client.server_capabilities[feature] if supported_client then break end diff --git a/lua/navigator/reference.lua b/lua/navigator/reference.lua index 38cb1ca..cfc3bdb 100644 --- a/lua/navigator/reference.lua +++ b/lua/navigator/reference.lua @@ -206,7 +206,7 @@ local ref = function() local ref_params = vim.lsp.util.make_position_params() vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, bufnr) - if client.resolved_capabilities.find_references then + if client.server_capabilities.referencesProvider then client.request('textDocument/references', ref_params, ref_hdlr, bufnr) end end) diff --git a/lua/navigator/symbols.lua b/lua/navigator/symbols.lua index 6f121bc..939f348 100644 --- a/lua/navigator/symbols.lua +++ b/lua/navigator/symbols.lua @@ -14,7 +14,8 @@ function M.workspace_symbols(query) local bufnr = vim.api.nvim_get_current_buf() local params = { query = query } vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, _bufnr) - if client.resolved_capabilities.workspace_symbol then + -- if client.resolved_capabilities.workspace_symbol then + if client.server_capabilities.workspaceSymbolProvider then client.request('workspace/symbol', params, M.workspace_symbol_handler, _bufnr) end end) @@ -35,7 +36,8 @@ function M.document_symbols(opts) params.context = { includeDeclaration = true } params.query = opts.prompt or '' vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, _bufnr) - if client.resolved_capabilities.document_symbol then + -- if client.resolved_capabilities.document_symbol then + if client.server_capabilities.documentSymbolProvider then client.request('textDocument/documentSymbol', params, M.document_symbol_handler, _bufnr) end end)