mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
refactor(lsp): narrower hierarchy
argument type (#34799)
This commit is contained in:

committed by
GitHub

parent
86a2ebd5fe
commit
2e2ac49c57
@@ -861,6 +861,13 @@ local function format_hierarchy_item(item)
|
|||||||
return string.format('%s %s', item.name, item.detail)
|
return string.format('%s %s', item.name, item.detail)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @alias vim.lsp.buf.HierarchyMethod
|
||||||
|
--- | 'typeHierarchy/subtypes'
|
||||||
|
--- | 'typeHierarchy/supertypes'
|
||||||
|
--- | 'callHierarchy/incomingCalls'
|
||||||
|
--- | 'callHierarchy/outgoingCalls'
|
||||||
|
|
||||||
|
--- @type table<vim.lsp.buf.HierarchyMethod, 'type' | 'call'>
|
||||||
local hierarchy_methods = {
|
local hierarchy_methods = {
|
||||||
[ms.typeHierarchy_subtypes] = 'type',
|
[ms.typeHierarchy_subtypes] = 'type',
|
||||||
[ms.typeHierarchy_supertypes] = 'type',
|
[ms.typeHierarchy_supertypes] = 'type',
|
||||||
@@ -868,12 +875,9 @@ local hierarchy_methods = {
|
|||||||
[ms.callHierarchy_outgoingCalls] = 'call',
|
[ms.callHierarchy_outgoingCalls] = 'call',
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @param method vim.lsp.protocol.Method.ClientToServer.Request
|
--- @param method vim.lsp.buf.HierarchyMethod
|
||||||
local function hierarchy(method)
|
local function hierarchy(method)
|
||||||
local kind = hierarchy_methods[method]
|
local kind = hierarchy_methods[method]
|
||||||
if not kind then
|
|
||||||
vim.notify(lsp._unsupported_method(method), vim.log.levels.WARN)
|
|
||||||
end
|
|
||||||
|
|
||||||
local prepare_method = kind == 'type' and ms.textDocument_prepareTypeHierarchy
|
local prepare_method = kind == 'type' and ms.textDocument_prepareTypeHierarchy
|
||||||
or ms.textDocument_prepareCallHierarchy
|
or ms.textDocument_prepareCallHierarchy
|
||||||
|
Reference in New Issue
Block a user