Skip to content

Feature: Add virtual workspace support #1007

@jianyexi

Description

@jianyexi

Summary

I'd like to propose adding virtual workspace support to ruff-vscode by exporting a registerUriTranslator API — the same pattern Pylance already uses.

Problem

The extension currently declares virtualWorkspaces.supported: false. This blocks Ruff from providing linting/formatting in virtual workspace environments (GitHub Repositories, Microsoft Fabric notebooks, custom FileSystemProvider workspaces).

No Python linter or formatter currently supports virtual workspaces (see microsoft/vscode-python#21459).

Proposed approach

Ruff exports registerUriTranslator(), the VFS provider owns the cache.

This is the exact pattern Pylance uses. The VFS provider extension (which already maintains a disk cache for its own purposes) registers a translator with Ruff:

const ruff = vscode.extensions.getExtension('charliermarsh.ruff');
await ruff.activate();
ruff.exports.registerUriTranslator({
  translateToDisk(uri)    { /* virtual URI → cached file:// URI */ },
  translateToVirtual(uri) { /* file:// URI → virtual URI */ },
  clearTranslationCache() { /* invalidate */ }
});

On registration, Ruff restarts its language server with LSP middleware that calls the translator.

Key point addressing the copy-all-files concern: Ruff does NOT need to copy any files itself. The VFS provider already maintains a persistent disk cache (for Pylance integration, editor operations, etc.). Ruff simply plugs into that existing cache via the translator interface. The caching is lazy — only files that are actually opened/referenced get cached by the VFS provider.

Changes needed in ruff-vscode

  1. package.json — set virtualWorkspaces.supported: true
  2. New src/common/uriTranslator.ts — interface definitions + registerUriTranslator export
  3. src/extension.tsactivate() returns the API; on registration triggers server restart
  4. src/common/server.ts — configure LSP middleware when translator is registered
  5. src/common/settings.ts / utilities.ts — handle non-file:// URI schemes

Zero changes needed in the Ruff binary — the native ruff server already speaks LSP and doesn't care about URI schemes.

Context

I work on the Microsoft Fabric Data Engineering VS Code extension which uses a custom VFS. We already register a URI translator with Pylance for Python IntelliSense. Adding the same integration for Ruff would give our users linting/formatting in virtual workspaces.

Environment

  • Extension version: 2026.40.0
  • Ruff version: Any (native server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions