gleam-lang/gleam

LSP: Show diagnostics for all packages currently open when using path deps

Open

#4,285 opened on Feb 27, 2025

View on GitHub
 (2 comments) (1 reaction) (0 assignees)Rust (21,417 stars) (960 forks)batch import
help wanted

Description

Hello! This is mainly an issue in monorepo-like setups, but when a breaking change is made in a Gleam project, it would be nice to have the LSP show diagnostics for any project in the current editor scope. Given this monorepo structure where the server project depends on types from the client project via a path dependency:

my_project
├── client
│   ├── gleam.toml
│   ├── manifest.toml
│   ├── src
│       └── client.gleam
└── server
    ├── gleam.toml
    ├── manifest.toml
    └── src
        └── server.gleam

If my editor opens to the my_project directory, I can see both projects simultaneously; however, I will only get LSP diagnostics for one project at a time (whichever one has the currently focused file). This is usually fine, but it becomes jarring when a breaking change is made in the client project and not warned about in the server project. Since the errors are only shown in the part of the codebase, it usually leads to me fixing all the errors in the client project, then running the project entry point in the server project, just to get another dump of errors in the console related to the change in the client project.

To fix this, I must navigate to a file in the server project and make a trivial edit to activate the LSP. After the edit, nice in-editor diagnostics in the server project will finally appear.

I used a simple, concrete example here, but this gets harder and more annoying to deal with given more projects in one repo.

Contributor guide