mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
refactor(lsp): use protocol.Methods instead of strings #24570
This commit is contained in:
@@ -1612,7 +1612,7 @@ function lsp.start_client(config)
|
|||||||
data = { client_id = client_id, request_id = id, request = request },
|
data = { client_id = client_id, request_id = id, request = request },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
return rpc.notify('$/cancelRequest', { id = id })
|
return rpc.notify(ms.dollar_cancelRequest, { id = id })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Track this so that we can escalate automatically if we've already tried a
|
-- Track this so that we can escalate automatically if we've already tried a
|
||||||
@@ -1636,9 +1636,9 @@ function lsp.start_client(config)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Sending a signal after a process has exited is acceptable.
|
-- Sending a signal after a process has exited is acceptable.
|
||||||
rpc.request('shutdown', nil, function(err, _)
|
rpc.request(ms.shutdown, nil, function(err, _)
|
||||||
if err == nil then
|
if err == nil then
|
||||||
rpc.notify('exit')
|
rpc.notify(ms.exit)
|
||||||
else
|
else
|
||||||
-- If there was an error in the shutdown request, then term to be safe.
|
-- If there was an error in the shutdown request, then term to be safe.
|
||||||
rpc.terminate()
|
rpc.terminate()
|
||||||
|
@@ -446,14 +446,14 @@ end
|
|||||||
--- |quickfix| window. If the symbol can resolve to multiple
|
--- |quickfix| window. If the symbol can resolve to multiple
|
||||||
--- items, the user can pick one in the |inputlist()|.
|
--- items, the user can pick one in the |inputlist()|.
|
||||||
function M.incoming_calls()
|
function M.incoming_calls()
|
||||||
call_hierarchy('callHierarchy/incomingCalls')
|
call_hierarchy(ms.callHierarchy_incomingCalls)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Lists all the items that are called by the symbol under the
|
--- Lists all the items that are called by the symbol under the
|
||||||
--- cursor in the |quickfix| window. If the symbol can resolve to
|
--- cursor in the |quickfix| window. If the symbol can resolve to
|
||||||
--- multiple items, the user can pick one in the |inputlist()|.
|
--- multiple items, the user can pick one in the |inputlist()|.
|
||||||
function M.outgoing_calls()
|
function M.outgoing_calls()
|
||||||
call_hierarchy('callHierarchy/outgoingCalls')
|
call_hierarchy(ms.callHierarchy_outgoingCalls)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- List workspace folders.
|
--- List workspace folders.
|
||||||
@@ -659,10 +659,10 @@ local function on_code_action_results(results, ctx, options)
|
|||||||
local reg = client.dynamic_capabilities:get(ms.textDocument_codeAction, { bufnr = ctx.bufnr })
|
local reg = client.dynamic_capabilities:get(ms.textDocument_codeAction, { bufnr = ctx.bufnr })
|
||||||
|
|
||||||
local supports_resolve = vim.tbl_get(reg or {}, 'registerOptions', 'resolveProvider')
|
local supports_resolve = vim.tbl_get(reg or {}, 'registerOptions', 'resolveProvider')
|
||||||
or client.supports_method('codeAction/resolve')
|
or client.supports_method(ms.codeAction_resolve)
|
||||||
|
|
||||||
if not action.edit and client and supports_resolve then
|
if not action.edit and client and supports_resolve then
|
||||||
client.request('codeAction/resolve', action, function(err, resolved_action)
|
client.request(ms.codeAction_resolve, action, function(err, resolved_action)
|
||||||
if err then
|
if err then
|
||||||
vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR)
|
vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user