Skip to content

Feature Request: Workspace Indexing Progress Notifications #148

@ewels

Description

@ewels

Summary

Add support for $/progress notifications during workspace indexing to allow LSP clients to display progress information to users.

Motivation

When opening a large Nextflow project, the language server takes significant time to index all .nf files before it can respond to requests like workspace/symbol or textDocument/documentSymbol. During this time, clients have no way to know:

  1. That indexing is in progress
  2. How far along the indexing is
  3. When indexing will complete

This results in a poor user experience where the editor/client appears to be "stuck" or unresponsive.

Proposed Solution

Implement the LSP Progress support for workspace indexing:

  1. Create a progress token during initialization using window/workDoneProgress/create
  2. Send $/progress notifications during the update() method in LanguageService.java with:
    • kind: "begin" when starting to index
    • kind: "report" with percentage (0-100) and/or message (e.g., "Indexing file 15/60") as files are processed
    • kind: "end" when indexing completes
Details

Example Progress Flow

-> window/workDoneProgress/create { token: "indexing" }
<- $/progress { token: "indexing", value: { kind: "begin", title: "Indexing workspace", percentage: 0 } }
<- $/progress { token: "indexing", value: { kind: "report", percentage: 25, message: "15/60 files" } }
<- $/progress { token: "indexing", value: { kind: "report", percentage: 50, message: "30/60 files" } }
<- $/progress { token: "indexing", value: { kind: "report", percentage: 100, message: "60/60 files" } }
<- $/progress { token: "indexing", value: { kind: "end", message: "Indexed 60 files" } }

Implementation Notes

In LanguageService.java, the update0() method already knows the set of URIs being processed:

private void update0() {
    // ...
    var uris = fileCache.removeChangedFiles();
    if( !scanned ) {
        if( uris.isEmpty() ) {
            uris = getWorkspaceFiles();  // <-- We know the total count here
            // Could send begin progress here
        }
    }
    // ...
    var changedUris = astCache.update(uris, fileCache);
    // Could send progress updates during astCache.update()
}

The ASTNodeCache.update() method could accept a progress callback or the total/current counts could be tracked and reported.

Benefits

  • Better user experience in VS Code and other editors
  • Enables CLI tools to show accurate progress bars
  • Aligns with LSP best practices for long-running operations

References

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