Skip to content
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

Support specifying default options through server settings #67

Open
rchl opened this issue Feb 15, 2023 · 8 comments
Open

Support specifying default options through server settings #67

rchl opened this issue Feb 15, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@rchl
Copy link
Contributor

rchl commented Feb 15, 2023

(Note that I haven't yet played with overriding settings so things I write below might be inaccurate. I did look through documentation though.)

I think it would make sense to be able to tell the server to use certain defaults (like line width 120) but still allow the project-specific overrides win. I believe that if one now specifies default line width through initializationOptions.settings.args then that will win over any other settings.

I saw in the documentation that it's possible to specify default settings in a file within home directory and that's fine but I would still prefer to specify defaults through LSP settings instead to keep everything contained within the server configuration.

I wonder what do you think about this.

@charliermarsh charliermarsh added the enhancement New feature or request label Feb 17, 2023
@charliermarsh
Copy link
Member

Your description is correct. The thing holding me back is that I'm not sure how best to enable this without further complicating Ruff's settings detection. I guess we could save any defaults to a TOML file locally, and then point Ruff to it (e.g., --default-config /path/to/tmp.toml).

@rchl
Copy link
Contributor Author

rchl commented Feb 20, 2023

Sound a bit hacky to generate a random file like that. I guess just supporting --default-config and requiring user to generate the file manually might be a better option after all.

@failable
Copy link

Does this mean ruff-lsp does not do config file discovery like ruff by default? I have ruff.toml in ~/Library/Application Support/ruff/ruff.toml but seems to be ignore by ruff-lsp but ruff.

@dsully
Copy link

dsully commented Oct 26, 2023

Related - it seems that the new ruff format uses the line length from

[tool.ruff]
line-length = 120

When used on the command line, but there doesn't appear to be any way to pass line-length specifically as format args via the LS. If a config file on disk does not exist, but lint.args = ... was set in the LS config, would formatting behave as expected?

@charliermarsh
Copy link
Member

No, it wouldn't respect the line length from lint.args -- that's only passed to the ruff check subcommand, the formatter under-the-hood is running ruff format, which doesn't support taking the line length on the command line. We could consider adding it!

@dsully
Copy link

dsully commented Oct 26, 2023

I think that would be extremely useful (and mirror how black's handles CLI arguments). I wasn't sure if it was better to ask here or in the ruff project.

@MichaReiser
Copy link
Member

I think we shouldn't promote the use of lint.args or format.args and instead add dedicated settings. My motivation for removing the need for the .args settings is that we intend to rewrite our LSP in Rust and directly call into a long-running server instead of spawning a CLI on every keystroke. This will give us much better performance and better error handling but it means that simply passing args no longer works (because there's no CLI to call).

@dsully
Copy link

dsully commented Oct 26, 2023

That's fantastic to hear - my request would then be a way to adjust the linter & formatter behavior via the LS settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants