Closed snowsignal closed 3 months ago
Sweet! Before I review the code itself, a few questions on the summary:
For example,
lint.args
/format.args
will be replaced in the future with specific configuration fields for the linter and formatter.
What does this mean in practice? Will there be a separate setting in VS Code for every configuration option in the linter and formatter?
Commands like
Fix all
andQuick Fix
have not yet been implemented. (code actions should still work, though)
What does it mean for Code Actions to work, but those commands to not work? What is an example of a Code Action that does work?
I'm still looking to understand the existing limitations of the LSP. I think it should meet some basic tablestakes functionality before we advertise it in any way, and parts of this PR feel like they are advertising it.
A few thoughts running this locally:
ruff
.2024-03-22 00:28:04.830 [info] 0.301909s ERROR ruff_server::session The following error occurred when trying to find a configuration file at `/private/tmp/ruff-vscode`:
No pyproject.toml/ruff.toml/.ruff.toml file was found
0.301931s ERROR ruff_server::session Falling back to default configuration for `/private/tmp/ruff-vscode`
notifications::did_open
and notifications::cancel
entries in the following. I think these are tracing logs which are being emitted.2024-03-22 00:33:53.544 [info] ┐ruff_server::server::api::notifications::did_open::run{file=file:///Users/dhruv/playground/ruff/formatter/main.py}
┘
2024-03-22 00:33:53.559 [info] [Trace - 12:33:53 AM] Received response 'textDocument/diagnostic - (1)' in 171ms.
2024-03-22 00:33:53.561 [info] [Trace - 12:33:53 AM] Sending notification '$/cancelRequest'.
2024-03-22 00:33:53.561 [info] [Trace - 12:33:53 AM] Sending request 'textDocument/codeAction - (3)'.
2024-03-22 00:33:53.565 [info] [Trace - 12:33:53 AM] Received response 'textDocument/codeAction - (2)' in 130ms.
2024-03-22 00:33:53.566 [info] ┐ruff_server::server::api::notifications::cancel::run{}
┘
2024-03-22 00:33:53.614 [info] [Trace - 12:33:53 AM] Received response 'textDocument/codeAction - (3)' in 53ms.
This is just a suggestion and not really required to be implemented but as the commands aren't implemented, maybe we could provide a info level log when a user tries to execute them. Currently, there's a log stating that there's no handler for the command in the server which users might find confusing.
We might want to clarify that we don't support source level code actions yet which means the editor.codeActionsOnSave
config wouldn't work.
I added the activation events for Jupyter Notebook back in package.json
and it's fine to do so as they will be ignored by the document selector setting. Confirmed that Notebooks aren't being picked up in that case.
@charliermarsh Thanks for your feedback, I just had a few questions:
I'm still looking to understand the existing limitations of the LSP.
I've tried to cover the limitations in the new section of the README.md
and in the MR description. Is there a different way I should be communicating these limitations? Is the list of limitations vague or missing items? Or is it something else?
I think it should meet some basic tablestakes functionality before we advertise it in any way, and parts of this PR feel like they are advertising it.
What do you think is missing from the LSP right now that should be table-stakes functionality?
@snowsignal - I mostly didn't understand this part, I asked about it above:
Commands like
Fix all
andQuick Fix
have not yet been implemented. (code actions should still work, though)
What does it mean for Code Actions to work, but those commands to not work? What is an example of a Code Action that does work?
What do you think is missing from the LSP right now that should be table-stakes functionality?
I was hoping that we'd support Fix All, Organize Imports, and Format. (Non-table-stakes would be like: Jupyter support, support for automatically adding the # noqa
suppressions as code actions, etc.). I'm okay with releasing without those capabilities if we want to test it and get into a shipping motion, I just don't know if we should publicize it in the README etc., since those are required for ~any user to use the LSP productively, I think.
What does it mean for Code Actions to work, but those commands to not work? What is an example of a Code Action that does work?
Sorry, I think the issue was that I've been using the term 'code actions' inter-changeably with 'quick fixes'. Quick Fixes are an example of a working Code Action - the only Code Actions that don't work yet should be Organize Imports
and Fix All
. I had a typo in the original limitations write-up that probably caused this confusion.
Before I take a second look at the code changes: Would you mind updating the PR summary with a test plan?
To confirm, this will be merged into a separate branch to enable us to keep releasing from main?
Right. These changes will reside solely in the pre-release
branch for now.
@MichaReiser I've added a test plan as requested.
@dhruvmanila
I don't think we should provide an error stating when the server isn't able to find the configuration file. This probably needs to be handled inside ruff.
Would it be okay to at least have a warning logged about this? I feel like this could be useful for catching issues with our configuration finder (instead of falling back silently)
We might want to clarify that we don't support source level code actions yet which means the editor.codeActionsOnSave config wouldn't work.
This is somewhat covered in the "we don't support extension configuration yet" bullet point, but I can revise it to point this out specifically.
Wow, that's a very detailed test plan. Thank you! What I like for test plans that involve visual elements is to record a short video that shows how I perform the individual steps. I find it more convenient because I don't enjoy writing a lot and it allows reviews (or people who stumble across this PR in the future) to easily see how the VS code extension looked as of your PR.
@MichaReiser Got it! I'll use videos for future PRs, and I'll try to add a video to this test plan when I get the chance.
@snowsignal - Def no need to add anything here, it's a great test plan! I think that's just advice for the future to save you time.
Summary
This is a pre-release edition of Ruff for VS Code that uses our new, Rust-based LSP -
ruff server
.At the moment, the pre-release has the following known limitations:
editor.codeActionsOnSave
does not work at the moment due to missing support for source-level code actions (see below). Additionally,lint.args
/format.args
will be replaced in the future with specific configuration fields for the linter and formatter.Fix all
andOrganize Imports
have not yet been implemented. (Quick Fixes should still work, though)ruff.toml
/pyproject.toml
at the workspace root to configure the formatter and linter.0.3.3
)These limitations will be addressed in future versions.
To use the new Rust-based language server, you'll need to enable the "Experimental Server" setting and reload the extension. The setting can be disabled again if you encounter any major issues with the new server.
Test Plan
To test the features of the new extension, please do the following:
Testing the Linter
def multiple_fixes(): x = True if x == False: print("this can't be good")