-
-
Notifications
You must be signed in to change notification settings - Fork 65
Add hierarchy lsp picker function #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,22 +253,34 @@ end | |
|
|
||
| local request = vim.lsp.buf_request | ||
|
|
||
| local function pick_hierarchy_lsp_client(bufnr, method) | ||
| bufnr = bufnr or 0 | ||
| method = method or vim.lsp.protocol.Methods.textDocument_prepareCallHierarchy | ||
| local file = vim.api.nvim_buf_get_name(bufnr) | ||
|
|
||
| for _, client in ipairs(vim.lsp.get_clients({ bufnr = bufnr, method = method })) do | ||
| if client.server_capabilities.callHierarchyProvider then | ||
| local root = client.config and client.config.root_dir | ||
| if not root or file:find(root, 1, true) == 1 then | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be? if root and file:find(root, 1, true) == 1Is there an example of lsp returns nil value for root_dir?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thoughts here were to not enforce |
||
| return client | ||
| end | ||
| end | ||
| end | ||
| return nil | ||
| end | ||
|
|
||
| -- call_hierarchy with floating window | ||
| call_hierarchy = function(method, opts) | ||
| local client = opts.client | ||
| local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() | ||
|
|
||
| log(method, opts, client, bufnr) | ||
| if not client then | ||
| local clients = vim.lsp.get_clients({ | ||
| bufnr = bufnr, | ||
| method = method, | ||
| }) | ||
| if not clients or #clients == 0 then | ||
| client = pick_hierarchy_lsp_client(bufnr, method) | ||
| if not client then | ||
| vim.notify('no call hierarchy clients found for bufnr') | ||
| return | ||
| end | ||
| client = clients[1] | ||
| end | ||
| trace(method, opts) | ||
| opts = opts or {} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I did not notice it was broken.