diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-04-23 19:05:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-23 19:05:01 +0200 |
commit | c81b7849a0f677164c01cf84ecfb25c1f47acf21 (patch) | |
tree | 31e11059634023a90d96d409ca8a5c3240b3fdbb /runtime/lua/vim/lsp/buf.lua | |
parent | 052498ed42780a76daea589d063cd8947a894673 (diff) | |
download | rneovim-c81b7849a0f677164c01cf84ecfb25c1f47acf21.tar.gz rneovim-c81b7849a0f677164c01cf84ecfb25c1f47acf21.tar.bz2 rneovim-c81b7849a0f677164c01cf84ecfb25c1f47acf21.zip |
refactor(lsp): merge subtypes and supertypes into typehierarchy (#28467)
Both methods had pretty much the same documentation and shared the
implementation.
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index fa0cbab138..79c1aeb53d 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -495,11 +495,17 @@ function M.outgoing_calls() call_hierarchy(ms.callHierarchy_outgoingCalls) end ---- @param method string -local function type_hierarchy(method) +--- Lists all the subtypes or supertypes of the symbol under the +--- cursor in the |quickfix| window. If the symbol can resolve to +--- multiple items, the user can pick one using |vim.ui.select()|. +---@param kind "subtypes"|"supertypes" +function M.typehierarchy(kind) + local method = kind == 'subtypes' and ms.typeHierarchy_subtypes or ms.typeHierarchy_supertypes + --- Merge results from multiple clients into a single table. Client-ID is preserved. --- --- @param results table<integer, {error: lsp.ResponseError, result: lsp.TypeHierarchyItem[]?}> + --- @return [integer, lsp.TypeHierarchyItem][] local function merge_results(results) local merged_results = {} for client_id, client_result in pairs(results) do @@ -525,11 +531,9 @@ local function type_hierarchy(method) end if #merged_results == 1 then - --- @type {integer, lsp.TypeHierarchyItem} local item = merged_results[1] local client = vim.lsp.get_client_by_id(item[1]) if client then - --- @type lsp.TypeHierarchyItem client.request(method, { item = item[2] }, nil, bufnr) else vim.notify( @@ -565,20 +569,6 @@ local function type_hierarchy(method) end) end ---- Lists all the subtypes of the symbol under the ---- cursor in the |quickfix| window. If the symbol can resolve to ---- multiple items, the user can pick one using |vim.ui.select()|. -function M.subtypes() - type_hierarchy(ms.typeHierarchy_subtypes) -end - ---- Lists all the supertypes of the symbol under the ---- cursor in the |quickfix| window. If the symbol can resolve to ---- multiple items, the user can pick one using |vim.ui.select()|. -function M.supertypes() - type_hierarchy(ms.typeHierarchy_supertypes) -end - --- List workspace folders. --- function M.list_workspace_folders() |