mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
![]() ## Summary Related to https://github.com/astral-sh/ruff-vscode/issues/571, this PR updates the settings index builder to trace all the errors it encountered. Without this, there's no way for user to know that something failed and some of the capability might not work as expected. For example, in the linked PR, the settings were invalid which means notebooks weren't included and there were no log messages for it. ## Test Plan Create an invalid `ruff.toml` file: ```toml [tool.ruff] extend-exclude = ["*.ipynb"] ``` Logs: ``` 2024-08-12 18:33:09.873 [info] [Trace - 6:33:09 PM] 12.217043000s ERROR ruff:main ruff_server::session::index::ruff_settings: Failed to parse /Users/dhruv/playground/ruff/pyproject.toml ``` Notification Preview: <img width="483" alt="Screenshot 2024-08-12 at 18 33 20" src="https://github.com/user-attachments/assets/a4f303e5-f073-454f-bdcd-ba6af511e232"> Another way to trigger is to provide an invalid `cache-dir` value: ```toml [tool.ruff] cache-dir = "$UNKNOWN" ``` Same notification preview but different log message: ``` 2024-08-12 18:41:37.571 [info] [Trace - 6:41:37 PM] 21.700112208s ERROR ThreadId(30) ruff_server::session::index::ruff_settings: Error while resolving settings from /Users/dhruv/playground/ruff/pyproject.toml: Invalid `cache-dir` value: error looking key 'UNKNOWN' up: environment variable not found ``` With multiple `pyproject.toml` file: ``` 2024-08-12 18:41:15.887 [info] [Trace - 6:41:15 PM] 0.016636833s ERROR ThreadId(04) ruff_server::session::index::ruff_settings: Error while resolving settings from /Users/dhruv/playground/ruff/pyproject.toml: Invalid `cache-dir` value: error looking key 'UNKNOWN' up: environment variable not found 2024-08-12 18:41:15.888 [info] [Trace - 6:41:15 PM] 0.017378833s ERROR ThreadId(13) ruff_server::session::index::ruff_settings: Failed to parse /Users/dhruv/playground/ruff/tools/pyproject.toml ``` |
||
---|---|---|
.. | ||
assets | ||
docs | ||
resources/test/fixtures | ||
src | ||
tests | ||
Cargo.toml | ||
CONTRIBUTING.md | ||
README.md |
The Ruff Language Server
ruff server
is a language server that powers Ruff's editor integrations.
The job of the language server is to listen for requests from the client (in this case, the code editor of your choice) and call into Ruff's linter and formatter crates to construct real-time diagnostics or formatted code, which is then sent back to the client. It also tracks configuration files in your editor's workspace, and will refresh its in-memory configuration whenever those files are modified.
Refer to the documentation for more information on how to set up the language server with your editor and configure it to your liking.
Contributing
Contributions are welcome and highly appreciated. To get started, check out the contributing guidelines.
You can also join us on Discord.