Skip to content

Clarification on workspace folders and roots in the initialize request #2154

@rcjsuen

Description

@rcjsuen
/**
 * The rootPath of the workspace. Is null
 * if no folder is open.
 *
 * @deprecated in favour of `rootUri`.
 */
rootPath?: string | null;

/**
 * The rootUri of the workspace. Is null if no
 * folder is open. If both `rootPath` and `rootUri` are set
 * `rootUri` wins.
 *
 * @deprecated in favour of `workspaceFolders`
 */
rootUri: DocumentUri | null;

/**
 * The workspace folders configured in the client when the server starts.
 * This property is only available if the client supports workspace folders.
 * It can be `null` if the client supports workspace folders but none are
 * configured.
 *
 * @since 3.6.0
 */
workspaceFolders?: WorkspaceFolder[] | null;
{
  "rootPath": "/tmp/lsp/question",
  "rootUri": "file:///tmp/lsp/question",
  "workspaceFolders": []
}
  1. If workspaceFolders is [], should we ignore rootUri and rootPath? I presume yes as it is still there and the language server should do its best to provide a trimmed down set of features and/or infer the "root" from opened files instead of deferring to rootUri and/or rootPath.
{
  "rootPath": "/tmp/lsp/question",
  "rootUri": "file:///tmp/lsp/question",
  "workspaceFolders": null
}
  1. If workspaceFolders is null, should we ignore rootUri and rootPath? I presume yes, per the documentation that "none are configured". So we should do the same as 1 above, right?
{
  "rootPath": "/no/scheme",
  "rootUri": ":/no/scheme"
}
  1. If workspaceFolders is completely missing, and rootUri is "" or an invalid URI, should the server respond with InvalidParams (-32602) or should the server just ignore it and use rootPath? 🤔

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions