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:
Justin M. Keyes
2025-10-11 21:25:54 -04:00
committed by GitHub
parent 4e4428dee8
commit 21540d21ca
5 changed files with 151 additions and 10 deletions

View File

@@ -1257,7 +1257,8 @@ Lua module: vim.lsp.client *lsp-client*
ephemerally while executing |LspRequest|
autocmds when replies are received from the
server.
• {root_dir} (`string?`) See |vim.lsp.ClientConfig|.
• {root_dir}? (`string|fun(bufnr: integer, on_dir:fun(root_dir?:string))`)
See |vim.lsp.ClientConfig|.
• {rpc} (`vim.lsp.rpc.PublicClient`) RPC client
object, for low level interaction with the
client. See |vim.lsp.rpc.start()|.
@@ -1407,9 +1408,10 @@ Lua module: vim.lsp.client *lsp-client*
You can only modify the
`client.offset_encoding` here before any
notifications are sent.
• {root_dir}? (`string`) Directory where the LSP server will
base its workspaceFolders, rootUri, and
rootPath on initialization.
• {root_dir}? (`string|fun(bufnr: integer, on_dir:fun(root_dir?:string))`)
Directory where the LSP server will base its
workspaceFolders, rootUri, and rootPath on
initialization.
• {settings}? (`lsp.LSPObject`) Map of language
server-specific settings, decided by the
client. Sent to the LS if requested via