Skip to content

feat: LSP root and document URI integration from backend#9143

Merged
mscolnick merged 3 commits intomarimo-team:mainfrom
daizutabi:feat-lsp-workspace
Apr 13, 2026
Merged

feat: LSP root and document URI integration from backend#9143
mscolnick merged 3 commits intomarimo-team:mainfrom
daizutabi:feat-lsp-workspace

Conversation

@daizutabi
Copy link
Copy Markdown
Contributor

📝 Summary

Closes #8662

This PR implements the frontend integration for the LSP workspace information provided by PR #9019. It updates all language server clients (pylsp, ty, pyrefly, basedpyright) to use the backend-resolved rootUri and workspaceFolders instead of computing them on the frontend.

Changes

1. LSP Utility Functions Migration

File: frontend/src/core/codemirror/lsp/utils.ts

Replaced frontend-side path computation with backend-provided values:

  • getLspRootUri(): Returns the backend-provided rootUri from lspWorkspaceAtom
  • getLspWorkspaceFolders(): Constructs workspace folders array from rootUri
  • getLspDocumentUri(): Returns the backend-provided documentUri from lspWorkspaceAtom

2. Language Server Client Updates

File: frontend/src/core/codemirror/language/languages/python.ts

Updated all four LSP clients with consistent initialization:

  • pylspClient: Uses new getLspRootUri() and getLspWorkspaceFolders()
  • tyLspClient: Uses new getLspRootUri() and getLspWorkspaceFolders()
  • pyreflyClient: Uses new getLspRootUri() and getLspWorkspaceFolders()
  • pyrightClient: Uses new getLspRootUri() and getLspWorkspaceFolders()

Verification (Screenshots)

Verified using a root pyproject.toml with:

[tool.basedpyright]
reportUnusedCallResult = false

Before

The project configuration is ignored because the workspace root was not specified. basedpyright incorrectly reports a warning on line 4 (func()) despite it being disabled in pyproject.toml.

After

The configuration is now correctly applied. The warning on line 4 is suppressed, while a legitimate type error (line 2) is still reported.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 13, 2026 9:12am

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 11, 2026

Bundle Report

Changes will increase total bundle size by 95 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 24.84MB 95 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/cells-*.js 95 bytes 703.48kB 0.01%

Files in assets/cells-*.js:

  • ./src/core/codemirror/lsp/utils.ts → Total Size: 421 bytes

  • ./src/core/codemirror/language/languages/python.ts → Total Size: 6.66kB

  • ./src/core/codemirror/lsp/notebook-lsp.ts → Total Size: 17.91kB

  • ./src/core/codemirror/lsp/federated-lsp.ts → Total Size: 4.29kB

@Light2Dark Light2Dark requested a review from Copilot April 13, 2026 04:33
@Light2Dark Light2Dark added the enhancement New feature or request label Apr 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Integrates backend-resolved LSP workspace information (root/document URIs) into the frontend so Python language servers use the correct project root (e.g., to pick up pyproject.toml-based basedpyright settings).

Changes:

  • Replaced frontend-derived LSP root/document URI computation with values read from lspWorkspaceAtom.
  • Updated Python LSP client initialization (pylsp/ty/pyrefly/basedpyright) to pass backend rootUri and derived workspaceFolders.
  • Updated LSP client wrappers/tests to use the backend-provided documentUri.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/core/codemirror/lsp/utils.ts Adds helpers to read backend-provided rootUri / documentUri from Jotai store.
frontend/src/core/codemirror/lsp/notebook-lsp.ts Switches merged document URI source to getLspDocumentUri().
frontend/src/core/codemirror/lsp/federated-lsp.ts Switches federated client document URI source to getLspDocumentUri().
frontend/src/core/codemirror/lsp/tests/notebook-lsp.test.ts Adjusts test setup/expectations for backend-provided document URI.
frontend/src/core/codemirror/language/languages/python.ts Initializes all Python LSP clients with backend rootUri + workspace folders.

Comment thread frontend/src/core/codemirror/lsp/utils.ts Outdated
Comment thread frontend/src/core/codemirror/lsp/utils.ts Outdated
@mscolnick mscolnick merged commit 326f659 into marimo-team:main Apr 13, 2026
25 checks passed
@daizutabi daizutabi deleted the feat-lsp-workspace branch April 13, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Marimo does not apply Basedpyright configurations in ./pyproject.toml

4 participants