-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ruff: Pass --preview
by default and make it configurable
#15157
Conversation
ruff
extension to use preview server by default--preview
by default and make it configurable
--preview
by default and make it configurable--preview
by default and make it configurable
FWIW, the user can already configure the flags passed to the language server:
Given that, I'd err on the side of not adding it. Edit: You need to pass in |
Ah thats great. I think it should be documented at least, since I had to look over ruff's release note and the zed's release note which is quite non-sense. |
After installing the new extension, and using Zed preview v. 0.146.0 on a mac, when I use this:
…in my settings.json, it seems to cause the ruff LSP to not work. (I also tried changing the name from My goal is not actually to pass the I am still able to use ruff as an external formatter using prior unofficial settings that don’t include the new ruff extension like this:
Below is the log of starting Zed using this lsp configuration:
It looks like the ruff extension is finding and running my global ruff install ( …and then maybe sending it a malformed query? If I start up Zed in the same test python project without the above LSP config, it logs like this (and ruff is working, but without my settings):
|
@pjv can you try with:
instead? My previous example is erroneous in that it should still contain |
@osiewicz thank you. So that makes the LSP work again, but it is ignoring my config (it’s formatting with 4 spaces where my config tells ruff to use 2 spaces) |
Hmm, are you able to grab a capture of the LSP request? Open your command palette -> search for My hunch is that when we ask Ruff for formatting, we also pass a bunch of settings related to the formatting from Zed: One of the options is the tab size. By default it's set to 4 spaces, which may take precedence over the config file you've passed in. If so, I'd say that's a bug on Ruff side. |
It looks like Ruff ignores the settings we pass in, so it has to be something else. |
|
What happens when you set |
You mean like this?:
…no difference. |
@osiewicz If I stick my global The workaround for me would be to uninstall the ruff extension and instead keep using the callout to my globally installed ruff as an external formatter for python files, but this seems suboptimal. EDIT: looking around here: https://docs.astral.sh/ruff/editors/settings/ …makes me think that maybe there could be a way to pass the configuration file path along in the |
The solution to getting the ruff extension to respect initialization options looks like this:
… which I had to arrive at by a long process of trial and error of sticking various combinations and orders of keys into the lsp object. So my question: is there a way that I could have looked at some documentation or even some code somewhere that would have made this not a trial and error but something that would have been obvious through understanding? How and where is this lsp object related to the language server extensions and is there any rhyme or reason to how that code is structured or is it 100% arbitrary in the case of each extension? |
It's 100% arbitrary for each extension, because we just pass the contents of |
@osiewicz No worries, thanks for confirming. So the pressure point is on extension authors to provide some minimum documentation. Good to know. |
Release Notes:
Although #15001 has merged to avoid passing
--preview
, executing without this flag is only supported on ruff binary versions higher than 0.5.3. Currently it does not work in environments where can't use latest ruff binary.Therefore, we need to set
--preview
as the default option to support older versions, while also making it configurable through settings.