Skip to content

lsp: Update root_path for compatibility with language servers#48587

Merged
SomeoneToIgnore merged 3 commits intozed-industries:mainfrom
shaz-r:fix-lsp-root-path
Feb 6, 2026
Merged

lsp: Update root_path for compatibility with language servers#48587
SomeoneToIgnore merged 3 commits intozed-industries:mainfrom
shaz-r:fix-lsp-root-path

Conversation

@shaz-r
Copy link
Contributor

@shaz-r shaz-r commented Feb 6, 2026

This PR updates the deprecated rootPath field in the LSP InitializeParams for backwards compatibility with language servers that still rely on this field.

Issue

Some language servers (notably the Salesforce Apex Language Server) only read from the deprecated rootPath field in the LSP initialize request and do not use rootUri or workspaceFolders.

When Zed sends root_path: None, these language servers fail to initialize because they cannot determine the workspace root.

Example error from the Apex Language Server:

NullPointerException
  at apex.jorje.lsp.impl.db.nddb.NdApexIndex.getToolsStoragePath(NdApexIndex.java:723)

The Apex LSP's initialize handler does:

serverSetup.setRootPath(params.getRootPath());

VSCode's LanguageClient sends both rootPath and rootUri for backwards compatibility:
https://github.com/microsoft/vscode-languageserver-node/blob/main/client/src/common/client.ts#L1434

Fix

Derive rootPath from the existing root_uri field when building the initialize params. The LSP spec states that if both rootPath and rootUri are provided, rootUri wins, so this change should be backwards compatible and won't affect language servers that properly use rootUri(1).


(1) LSP Specification - InitializeParams - notes that rootPath is deprecated in favor of workspaceFolders, but for backwards compatibility it should still be provided when possible.

Release Notes:

  • Improved compatibility with legacy language servers

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 6, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Feb 6, 2026
@maxdeviant maxdeviant changed the title LSP - Update root_path for compatibility with language servers lsp: Update root_path for compatibility with language servers Feb 6, 2026
@SomeoneToIgnore SomeoneToIgnore self-assigned this Feb 6, 2026
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) February 6, 2026 16:40
@SomeoneToIgnore
Copy link
Contributor

Looks like we need to annotate the test with warning suppressions or remove the test.

auto-merge was automatically disabled February 6, 2026 22:07

Head branch was pushed to by a user without write access

@shaz-r
Copy link
Contributor Author

shaz-r commented Feb 6, 2026

Looks like we need to annotate the test with warning suppressions or remove the test.

I've added allow(deprecated) to the fields in the test.

@shaz-r
Copy link
Contributor Author

shaz-r commented Feb 6, 2026

Fixed the failing fmt (extra new line).

@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) February 6, 2026 23:25
@SomeoneToIgnore SomeoneToIgnore merged commit 641c58d into zed-industries:main Feb 6, 2026
27 checks passed
@shaz-r shaz-r deleted the fix-lsp-root-path branch February 6, 2026 23:59
baldwindavid added a commit to baldwindavid/zed that referenced this pull request Feb 9, 2026
* main: (57 commits)
  agent: Fix disabled MCP servers disappearing from UI after restart (zed-industries#47758)
  Update Rust crate git2 to v0.20.4 [SECURITY] (zed-industries#48400)
  Update Rust crate time to v0.3.47 [SECURITY] (zed-industries#48514)
  gpui: Reset `external_files_dragged` after successful drag-drop on macOS (zed-industries#48727)
  language: Return early if no grammars are added (zed-industries#48685)
  Properly handle multi-char folds (zed-industries#48721)
  collab: Proxy `GET /extensions` to Cloud (zed-industries#48717)
  git: Fix a potential misalignment in the side-by-side diff (zed-industries#48690)
  Move extension API DTOs into `cloud_api_types` (zed-industries#48689)
  git: Add a setting for the default view mode of `SplittableEditor` (zed-industries#48440)
  Use proper settings name for semantic tokens' settings UI (zed-industries#48686)
  gpui: Fix restarting panicking due to double borrows on windows (zed-industries#48667)
  Strip broken thinking blocks from Anthropic requests (zed-industries#48548)
  keymap_editor: Add `alt-l` keybinding for cycling favorite models (zed-industries#48390)
  Only raise Windows timer resolution while blocking with timeout (zed-industries#48379)
  editor: Propagate `buffer_font_features` to signatureHelp popover (zed-industries#48653)
  Add configurable LSP timeout setting (zed-industries#44745)
  editor: Use buffer_font for folds and change foreground color (zed-industries#48652)
  lsp: Update root_path for compatibility with language servers (zed-industries#48587)
  Fix panic with LSP folds on disappearing excerpts (zed-industries#48649)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants