-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add glob to match filetype #10960
Add glob to match filetype #10960
Changes from all commits
3600095
a4fa102
de003ba
24ea7a8
addeb46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ | |||||||||
use crate::{File, Language, LanguageServerName}; | ||||||||||
use anyhow::Result; | ||||||||||
use collections::{HashMap, HashSet}; | ||||||||||
use globset::GlobMatcher; | ||||||||||
use globset::{Glob, GlobMatcher, GlobSet, GlobSetBuilder}; | ||||||||||
use gpui::AppContext; | ||||||||||
use itertools::{Either, Itertools}; | ||||||||||
use schemars::{ | ||||||||||
|
@@ -54,7 +54,7 @@ pub struct AllLanguageSettings { | |||||||||
pub copilot: CopilotSettings, | ||||||||||
defaults: LanguageSettings, | ||||||||||
languages: HashMap<Arc<str>, LanguageSettings>, | ||||||||||
pub(crate) file_types: HashMap<Arc<str>, Vec<String>>, | ||||||||||
pub(crate) file_types: Option<HashMap<Arc<str>, GlobSet>>, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
/// The settings for a particular language. | ||||||||||
|
@@ -563,7 +563,7 @@ impl settings::Settings for AllLanguageSettings { | |||||||||
.and_then(|c| c.disabled_globs.as_ref()) | ||||||||||
.ok_or_else(Self::missing_default)?; | ||||||||||
|
||||||||||
let mut file_types: HashMap<Arc<str>, Vec<String>> = HashMap::default(); | ||||||||||
let mut file_types: Option<HashMap<Arc<str>, GlobSet>> = Some(HashMap::default()); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm pretty sure that we may be able to omit the type altogether, though I can't check that rn:
Suggested change
|
||||||||||
for user_settings in sources.customizations() { | ||||||||||
if let Some(copilot) = user_settings.features.as_ref().and_then(|f| f.copilot) { | ||||||||||
copilot_enabled = copilot; | ||||||||||
|
@@ -594,10 +594,14 @@ impl settings::Settings for AllLanguageSettings { | |||||||||
} | ||||||||||
|
||||||||||
for (language, suffixes) in &user_settings.file_types { | ||||||||||
let mut builder = GlobSetBuilder::new(); | ||||||||||
for suffix in suffixes { | ||||||||||
builder.add(Glob::new(suffix)?); | ||||||||||
} | ||||||||||
file_types | ||||||||||
.entry(language.clone()) | ||||||||||
.or_default() | ||||||||||
.extend_from_slice(suffixes); | ||||||||||
.as_mut() | ||||||||||
.unwrap() | ||||||||||
.insert(language.clone(), builder.build()?); | ||||||||||
Comment on lines
+602
to
+604
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.