microsoft / microsoft/language-server-protocol

Clarification on workspace folders and roots in the initialize request

Open
#2,154 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clarification
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

/**
 * 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? 🤔

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the initialize request definitions for rootPath, rootUri, and workspaceFolders, then resolve the behavior for empty, null, missing, and invalid values described in the examples. Done means the protocol semantics are decided and the clarification is recorded in the relevant documentation or specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.