Skip to content

Support LSP 3.18 workspace/textDocumentContent, for documents a server provides under its own URI schemes #1744

Closed

Description

@lagergren

Feature request. Could a maintainer give it the enhancement label and the Feature type? I can't set them on this repository.

LSP 3.18 (proposed) adds a standard way for a server to provide the content of documents that aren't files on disk, under a URI scheme the server owns: library sources, decompiled classes, generated code or documentation. LSP4IJ doesn't support it yet:

  • it doesn't advertise workspace.textDocumentContent;
  • it doesn't send workspace/textDocumentContent;
  • it doesn't answer workspace/textDocumentContent/refresh.

So a server has to fall back to files on disk, or to a request of its own, such as jdt.ls's java/classFileContents.

The protocol

From LSP 3.18, proposed:

  • The client capability workspace.textDocumentContent, with dynamicRegistration.
  • The server capability, or a dynamic registration, workspace.textDocumentContent, with the schemes the server provides content for.
  • workspace/textDocumentContent, from client to server: { uri } → { text }. "Clients should treat the content returned from this request as read-only."
  • workspace/textDocumentContent/refresh, from server to client: { uri }. The client then requests the content again.

LSP4J 1.0.0, which LSP4IJ uses, already has the types and the service methods: WorkspaceService.textDocumentContent and LanguageClient.refreshTextDocumentContent, marked @ProtocolDraft.

VS Code's language client implements it: it registers a read-only content provider for each scheme the server lists, and handles refresh.

What it would take in LSP4IJ

  • Advertise the capability, and record the schemes from the server's capabilities and registrations.
  • Resolve a URI with one of those schemes, from a definition, a reference or a document link, to a read-only virtual file, whose text comes from workspace/textDocumentContent. Navigation then opens it in an editor.
  • Connect the document to its server like any other, with didOpen for that URI, so that language features work in that editor.
  • On workspace/textDocumentContent/refresh, request the content again, and update the open editors.
  • Release the virtual files when the server stops or unregisters the scheme.

Our language server, for Ecstasy, uses this for library sources in VS Code. In IntelliJ, it falls back to read-only files on disk. I'd be glad to help with a pull request if you're interested.

Activity

  1. moved this to In Progress in Java Toolingon Oct 20, 2026
  2. added
    enhancement
    on Oct 20, 2026
  3. added this to the 0.21.1 milestone on Oct 20, 2026
  4. lagergren commented on Oct 20, 2026

    @lagergren
    CollaboratorAuthor

    Implemented by #1749, merged as e3a9b11.

  5. moved this from In Progress to Done in Java Toolingon Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions