Open jamesvrt opened 2 months ago
Do you see anything in the logs? Refer to the troubleshooting guide.
There was a bug that's been fixed in https://github.com/astral-sh/ruff-lsp/pull/485, I'll bump the version of ruff-lsp
today to get it out.
Including
"ruff.nativeServer": "off"
insettings.json
resolves the issue.
What do you mean by this? Like, using the ruff-lsp
resolves the issue? But, the issue title says that it doesn't work with ruff-lsp
?
What do you mean by this?
Sorry, typo! I meant:
Including "ruff.nativeServer": "on" in settings.json resolves the issue.
I updated the issue. So using the Rust based version is a workaround. I'll try the updated ruff-lsp
when it's out.
Do you see anything in the logs? Refer to the troubleshooting guide.
Sorry, I missed that bit. Logs:
2024-09-05 09:31:17.874 [info] [Trace - 9:31:17 AM] Sending request 'textDocument/rangeFormatting - (6)'.
2024-09-05 09:31:17.877 [info] [Trace - 9:31:17 AM] Received notification 'window/logMessage'.
2024-09-05 09:31:17.877 [info] Using interpreter executable: /home/jamesvrt/miniconda3/envs/test/bin/ruff
2024-09-05 09:31:17.877 [info] [Trace - 9:31:17 AM] Received notification 'window/logMessage'.
2024-09-05 09:31:17.877 [info] Found ruff 0.6.3 at /home/jamesvrt/miniconda3/envs/test/bin/ruff
2024-09-05 09:31:17.877 [info] [Trace - 9:31:17 AM] Received notification 'window/logMessage'.
2024-09-05 09:31:17.877 [info] Running Ruff with: /home/jamesvrt/miniconda3/envs/test/bin/ruff ['format', '--force-exclude', '--quiet', '--stdin-filename', '/home/jamesvrt/code/test/test.ipynb', '--config', 'line-length=120']
@jamesvrt the new ruff-lsp
version is out, can you try it out?
Although I don't see any error in the logs :(
Also, I'd recommend to switch over to the Rust based server as it has the same functionalities (+ a few more) with no additional installation and high performance :)
How do you get the VSCode extension to use the latest ruff-lsp
? The latest extension version still uses the previous ruff-lsp
and it doesn't pick up ruff-lsp
in my Python environment, only ruff
.
BTW, I'm content to use ruff
rather than ruff-lsp
since it's faster anyway.
How do you get the VSCode extension to use the latest
ruff-lsp
? The latest extension version still uses the previousruff-lsp
and it doesn't pick upruff-lsp
in my Python environment, onlyruff
.
Ah right, sorry. I'd need to release a new VS Code extension as well.
I've released a new extension version which should be available in a couple of minutes.
Just to say I've been having similar issues as the people above.
adding "ruff.nativeServer": "on" to my workspace's settings.json got ruff formatting my notebook cells again.
However, I'm on the latest version of your extension, v2024.44.0
so should setting that explicitly have been necessary?
I'm also on ruff 0.6.4 everywhere else and in the documentation I think it says that it should default to the native server without explicit setting?
@HenryDashwood can you share the VS Code settings and Ruff logs? I just tested with 2024.44.0
VS Code with ruff.nativeServer: "off"
and it works. And, it doesn't work when using ruff-lsp
with 2024.42.0
.
ruff-lsp
still doesn't work for me with the VSCode extension version 2024.44.0. Logs:
2024-09-09 09:13:16.808 [info] Interpreter executable (/home/jamesvrt/miniconda3/envs/test/bin/ruff) not found
2024-09-09 09:13:16.808 [info] [Trace - 9:13:16 AM] Received notification 'window/logMessage'.
2024-09-09 09:13:16.808 [info] Falling back to bundled executable: /home/jamesvrt/.vscode/extensions/charliermarsh.ruff-2024.44.0-linux-x64/bundled/libs/bin/ruff
2024-09-09 09:13:16.808 [info] [Trace - 9:13:16 AM] Received notification 'window/logMessage'.
2024-09-09 09:13:16.808 [info] Found ruff 0.6.4 at /home/jamesvrt/.vscode/extensions/charliermarsh.ruff-2024.44.0-linux-x64/bundled/libs/bin/ruff
2024-09-09 09:13:16.808 [info] [Trace - 9:13:16 AM] Received notification 'window/logMessage'.
2024-09-09 09:13:16.808 [info] Running Ruff with: /home/jamesvrt/.vscode/extensions/charliermarsh.ruff-2024.44.0-linux-x64/bundled/libs/bin/ruff ['format', '--force-exclude', '--quiet', '--stdin-filename', '/home/jamesvrt/code/test/test.ipynb', '--config', 'line-length=120']
2024-09-09 09:13:16.812 [info] [Trace - 9:13:16 AM] Received response 'textDocument/rangeFormatting - (15)' in 6ms.
Appreciate your hard work with ruff
btw!
2024-09-09 09:13:16.812 [info] [Trace - 9:13:16 AM] Received response 'textDocument/rangeFormatting - (15)' in 6ms.
I think we don't support range formatting for Notebooks in ruff-lsp
and that's only supported in the native server. Can you try running other formatting operations that apply on the entire notebook and verify? Although it might just be better to completely switch to the native server ;)
"Format Notebook", "Format Cell" and "Format Range" don't work, but "Ruff: Format document" (only available through ctrl+shift+P) does work. I need more granular control than document formatting, so I'll stick with the native server. Thanks!
You can set this to closed if this is expected behaviour, though it might be nice to mention it in the extension page or default to the native server.
"Format Notebook", "Format Cell" and "Format Range" don't work, but "Ruff: Format document" (only available through ctrl+shift+P) does work.
Oh, that's unexpected and could very well be a bug in ruff-lsp
. I think at least "Format Notebook" and "Format Cell" are suppose to work.
@HenryDashwood can you share the VS Code settings and Ruff logs? I just tested with
2024.44.0
VS Code withruff.nativeServer: "off"
and it works. And, it doesn't work when usingruff-lsp
with2024.42.0
.
Tried to replicate this evening and couldn't I'm afraid. But I guess that does mean it's working!
Create
test.ipynb
, create a cell withPerform Format Select/Cell/Document/Notebook via ctrl+shift+P, the right click menu or the keyboard shortcuts.
No changes observed in the cell.
Ruff output:
Performing
ruff format test.ipynb
on the CLI works as expected.Including
"ruff.nativeServer": "on"
insettings.json
resolves the issue.pyproject.toml
andsettings.json
).No
ruff.toml
orpyproject.toml
settings.json
includes:ruff --version
).ruff 0.6.3 ruff vscode extension 2024.42.0
Ubuntu 22.04 VSCode 1.92.2 Python 3.10.11