mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
ruff server
reads from a configuration TOML file in the user configuration directory if no local configuration exists (#11225)
## Summary Fixes https://github.com/astral-sh/ruff/issues/11158. A settings file in the ruff user configuration directory will be used as a configuration fallback, if it exists. ## Test Plan Create a `pyproject.toml` or `ruff.toml` configuration file in the ruff user configuration directory. * On Linux, that will be `$XDG_CONFIG_HOME/ruff/` or `$HOME/.config` * On macOS, that will be `$HOME/Library/Application Support` * On Windows, that will be `{FOLDERID_LocalAppData}` Then, open a file inside of a workspace with no configuration. The settings in the user configuration file should be used.
This commit is contained in:
parent
1f217d54d0
commit
068e22d382
1 changed files with 16 additions and 2 deletions
|
@ -4,7 +4,7 @@ use ruff_linter::{
|
|||
};
|
||||
use ruff_workspace::{
|
||||
configuration::{Configuration, FormatConfiguration, LintConfiguration, RuleSelection},
|
||||
pyproject::settings_toml,
|
||||
pyproject::{find_user_settings_toml, settings_toml},
|
||||
resolver::{ConfigurationTransformer, Relativity},
|
||||
};
|
||||
use std::{
|
||||
|
@ -80,9 +80,23 @@ impl RuffSettingsIndex {
|
|||
}
|
||||
}
|
||||
|
||||
let fallback = find_user_settings_toml()
|
||||
.and_then(|user_settings| {
|
||||
ruff_workspace::resolver::resolve_root_settings(
|
||||
&user_settings,
|
||||
Relativity::Cwd,
|
||||
&EditorConfigurationTransformer(editor_settings, root),
|
||||
)
|
||||
.ok()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
Self {
|
||||
index,
|
||||
fallback: Arc::default(),
|
||||
fallback: Arc::new(RuffSettings {
|
||||
formatter: fallback.formatter,
|
||||
linter: fallback.linter,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue