Skip to content

Conversation

@mhuisi
Copy link
Collaborator

@mhuisi mhuisi commented Jan 16, 2026

This PR adds for language server support for nested Lean projects. With this PR, nested Lean projects do not yield an error anymore. Files in nested projects are associated with the innermost language client containing them.

Other changes

  • The lean4.fallBackToStringOccurrenceHighlighting is removed. We put this functionality behind the lean4.fallBackToStringOccurrenceHighlighting setting (that is disabled by default) in feat: customizable occurrence highlighting #377 with the goal of removing it eventually.
  • The language client library is updated from 8.0.2 to 9.0.2.

Implementation notes

Support for nested Lean projects was not deemed possible previously due to inadequate support for nested language clients in VS Code's language client library. In the language client library (and the VS Code API), files are associated with a language client (or in VS Code with a specific editor functionality) via globs. Hence, nesting two projects would associate the Lean files of the inner project with both the inner and the outer language client, duplicating language server support (e.g. producing duplicate hovers). These globs cannot express subfolder exclusions.

In this PR, we work around this limitation by abusing the general request and notification middleware extension points of the language client library to filter requests and notifications for excluded subfolders (i.e. inner Lean projects).
For notifications, this is as simple as not emitting the message. For requests, the API does not permit filtering a generic request, so we use another hack: the new middleware throws a ContentModified exception for filtered requests, for which the current code of the language client library ensures that it is not displayed to the user and that it returns a default value. For every request type, this default value is chosen by the language client library such that VS Code will ignore the provider of the language client that produces it and query another provider to obtain a result. Thus, we can use this mechanism to triage requests for files in an inner project by letting them pass through to the inner language server and filtering them from communication with the outer language server.

@mhuisi mhuisi merged commit 7dfbc35 into leanprover:master Jan 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant