leanprover / leanprover/lean4

Lean's LSP internals appear in autocompletes for `IO.FS.Stream`

Open
#6,135 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Description

When a library transitively imports the Lean language server, then various functions that it defines in the IO.FS.Stream namespace show up in completion results for streams. In fact, they make up the majority of these completion results!

This could easily hit a user who's downstream of Verso or Alloy, both of which define their own LSP handlers.

Context

This came up when working on the IO chapter of the reference manual, but it's not a blocker in the slightest.

Steps to Reproduce
  1. Open a new empty Lean file and type #check IO.FS.Stream. and invoke completion.
  2. Observe the completion list
  3. Add import Lean as the first line of the file
  4. Invoke completion in the same position as before, and observe the completion list

Expected behavior:

I would expect that the completions were unchanged.

Actual behavior:

The majority of the completions list has to do with JSON-RPC and LSP, giving the impression that this is the purpose of IO.FS.Stream.

Suggestions

I think this could be solved in two ways in the language server:

  1. Get those functions out of the namespace. This would make the experience of working on the LSP server a bit worse, because dot-completion would no longer select those functions.

  2. Define abbref LspStream := IO.FS.Stream and then put the functions in the LSPStream namespace. This would spare downstream users from seeing them, and also perhaps make it marginally more clear which role a given stream plays.

Versions

"4.15.0-nightly-2024-11-19", on live.lean-lang.org.

Impact

I think this is a papercut at worst.

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the completion difference for IO.FS.Stream. in an empty file with and without import Lean. Read the IO.FS.Stream namespace and the Lean language-server LSP definitions, then determine how the LSP functions can be separated from downstream stream completions. Done means the completion list no longer presents JSON-RPC and LSP functions as the majority of IO.FS.Stream results.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.