mirror of
https://github.com/neovim/neovim.git
synced 2025-10-13 05:16:09 +00:00
fix(lsp): _get_workspace_folders does not handle root_dir() function (#36141)
backport #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: atusy <30277794+atusy@users.noreply.github.com>
This commit is contained in:
@@ -54,7 +54,7 @@ function lsp._unsupported_method(method)
|
||||
end
|
||||
|
||||
---@private
|
||||
---@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
|
||||
@@ -66,6 +66,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