Support .editorconfig (#19455)
Closes https://github.com/zed-industries/zed/issues/8534 Supersedes https://github.com/zed-industries/zed/pull/16349 Potential concerns: * we do not follow up to the `/` when looking for `.editorconfig`, only up to the worktree root. Seems fine for most of the cases, and the rest should be solved generically later, as the same issue exists for settings.json * `fn language` in `AllLanguageSettings` is very hot, called very frequently during rendering. We accumulate and parse all `.editorconfig` file contents beforehand, but have to go over globs and match these against the path given + merge the properties still. This does not seem to be very bad, but needs more testing and potentially some extra caching. Release Notes: - Added .editorconfig support --------- Co-authored-by: Ulysse Buonomo <buonomo.ulysse@gmail.com>
This commit is contained in:
parent
d95a4f8671
commit
d3cb08bf35
30 changed files with 869 additions and 263 deletions
|
@ -62,7 +62,7 @@ impl Render for InlineCompletionButton {
|
|||
let status = copilot.read(cx).status();
|
||||
|
||||
let enabled = self.editor_enabled.unwrap_or_else(|| {
|
||||
all_language_settings.inline_completions_enabled(None, None)
|
||||
all_language_settings.inline_completions_enabled(None, None, cx)
|
||||
});
|
||||
|
||||
let icon = match status {
|
||||
|
@ -248,8 +248,9 @@ impl InlineCompletionButton {
|
|||
|
||||
if let Some(language) = self.language.clone() {
|
||||
let fs = fs.clone();
|
||||
let language_enabled = language_settings::language_settings(Some(&language), None, cx)
|
||||
.show_inline_completions;
|
||||
let language_enabled =
|
||||
language_settings::language_settings(Some(language.name()), None, cx)
|
||||
.show_inline_completions;
|
||||
|
||||
menu = menu.entry(
|
||||
format!(
|
||||
|
@ -292,7 +293,7 @@ impl InlineCompletionButton {
|
|||
);
|
||||
}
|
||||
|
||||
let globally_enabled = settings.inline_completions_enabled(None, None);
|
||||
let globally_enabled = settings.inline_completions_enabled(None, None, cx);
|
||||
menu.entry(
|
||||
if globally_enabled {
|
||||
"Hide Inline Completions for All Files"
|
||||
|
@ -340,6 +341,7 @@ impl InlineCompletionButton {
|
|||
&& all_language_settings(file, cx).inline_completions_enabled(
|
||||
language,
|
||||
file.map(|file| file.path().as_ref()),
|
||||
cx,
|
||||
),
|
||||
)
|
||||
};
|
||||
|
@ -442,7 +444,7 @@ async fn configure_disabled_globs(
|
|||
|
||||
fn toggle_inline_completions_globally(fs: Arc<dyn Fs>, cx: &mut AppContext) {
|
||||
let show_inline_completions =
|
||||
all_language_settings(None, cx).inline_completions_enabled(None, None);
|
||||
all_language_settings(None, cx).inline_completions_enabled(None, None, cx);
|
||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||
file.defaults.show_inline_completions = Some(!show_inline_completions)
|
||||
});
|
||||
|
@ -466,7 +468,7 @@ fn toggle_inline_completions_for_language(
|
|||
cx: &mut AppContext,
|
||||
) {
|
||||
let show_inline_completions =
|
||||
all_language_settings(None, cx).inline_completions_enabled(Some(&language), None);
|
||||
all_language_settings(None, cx).inline_completions_enabled(Some(&language), None, cx);
|
||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||
file.languages
|
||||
.entry(language.name())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue