mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 23:31:51 +00:00
fix(lsp): _get_workspace_folders does not handle root_dir() function #36071
* fix(lsp): type of root_dir should be annotated with string|fun|nil * feat(lsp): support root_dir as function in _get_workspace_folders * feat(lsp): let checkhealth support root_dir() function Examples: vim.lsp: Active Clients ~ - lua_ls (id: 1) - Version: <Unknown> - Root directories: ~/foo/bar ~/dev/neovim Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
@@ -56,7 +56,7 @@ function lsp._unsupported_method(method)
|
||||
return msg
|
||||
end
|
||||
|
||||
---@param workspace_folders string|lsp.WorkspaceFolder[]?
|
||||
---@param workspace_folders string|lsp.WorkspaceFolder[]|fun(bufnr: integer, on_dir:fun(root_dir?:string))?
|
||||
---@return lsp.WorkspaceFolder[]?
|
||||
function lsp._get_workspace_folders(workspace_folders)
|
||||
if type(workspace_folders) == 'table' then
|
||||
@@ -68,6 +68,15 @@ function lsp._get_workspace_folders(workspace_folders)
|
||||
name = workspace_folders,
|
||||
},
|
||||
}
|
||||
elseif type(workspace_folders) == 'function' then
|
||||
local name = lsp.client._resolve_root_dir(1000, 0, workspace_folders)
|
||||
return name
|
||||
and {
|
||||
{
|
||||
uri = vim.uri_from_fname(name),
|
||||
name = name,
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user