mirror of
https://github.com/sharkdp/bat
synced 2024-11-24 12:53:22 +00:00
Revert to previous commit
This commit is contained in:
parent
6bc477e88f
commit
31fb7087f1
2 changed files with 6 additions and 27 deletions
|
@ -86,19 +86,6 @@ pub fn list_languages(config: &Config) -> Result<()> {
|
||||||
.filter(|syntax| !syntax.hidden && !syntax.file_extensions.is_empty())
|
.filter(|syntax| !syntax.hidden && !syntax.file_extensions.is_empty())
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
for lang in languages.iter_mut() {
|
|
||||||
let lang_name = lang.name.clone();
|
|
||||||
lang.file_extensions.retain(|extension| {
|
|
||||||
let test_file = Path::new("test").with_extension(extension);
|
|
||||||
match config.syntax_mapping.get_syntax_for(test_file) {
|
|
||||||
Some(MappingTarget::MapTo(primary_lang)) => lang_name == primary_lang,
|
|
||||||
Some(MappingTarget::MapToUnknown) => false,
|
|
||||||
None => true,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
languages.sort_by_key(|lang| lang.name.to_uppercase());
|
languages.sort_by_key(|lang| lang.name.to_uppercase());
|
||||||
|
|
||||||
let configured_languages = get_syntax_mapping_to_paths(config.syntax_mapping.mappings());
|
let configured_languages = get_syntax_mapping_to_paths(config.syntax_mapping.mappings());
|
||||||
|
|
|
@ -24,12 +24,6 @@ impl<'a> SyntaxMapping<'a> {
|
||||||
let mut mapping = Self::empty();
|
let mut mapping = Self::empty();
|
||||||
mapping.insert("*.h", MappingTarget::MapTo("C++")).unwrap();
|
mapping.insert("*.h", MappingTarget::MapTo("C++")).unwrap();
|
||||||
mapping.insert("*.fs", MappingTarget::MapTo("F#")).unwrap();
|
mapping.insert("*.fs", MappingTarget::MapTo("F#")).unwrap();
|
||||||
mapping
|
|
||||||
.insert("*.js", MappingTarget::MapTo("JavaScript (Babel)"))
|
|
||||||
.unwrap();
|
|
||||||
mapping
|
|
||||||
.insert("*.sass", MappingTarget::MapTo("Sass"))
|
|
||||||
.unwrap();
|
|
||||||
mapping
|
mapping
|
||||||
.insert("build", MappingTarget::MapToUnknown)
|
.insert("build", MappingTarget::MapToUnknown)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -98,16 +92,14 @@ impl<'a> SyntaxMapping<'a> {
|
||||||
"*.swap",
|
"*.swap",
|
||||||
"*.target",
|
"*.target",
|
||||||
"*.timer",
|
"*.timer",
|
||||||
]
|
].iter() {
|
||||||
.iter()
|
mapping
|
||||||
{
|
.insert(glob, MappingTarget::MapTo("INI"))
|
||||||
mapping.insert(glob, MappingTarget::MapTo("INI")).unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// pacman hooks
|
// pacman hooks
|
||||||
mapping
|
mapping.insert("*.hook", MappingTarget::MapTo("INI")).unwrap();
|
||||||
.insert("*.hook", MappingTarget::MapTo("INI"))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
mapping
|
mapping
|
||||||
}
|
}
|
||||||
|
@ -125,7 +117,7 @@ impl<'a> SyntaxMapping<'a> {
|
||||||
&self.mappings
|
&self.mappings
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_syntax_for(&self, path: impl AsRef<Path>) -> Option<MappingTarget<'a>> {
|
pub(crate) fn get_syntax_for(&self, path: impl AsRef<Path>) -> Option<MappingTarget<'a>> {
|
||||||
let candidate = Candidate::new(path.as_ref());
|
let candidate = Candidate::new(path.as_ref());
|
||||||
let candidate_filename = path.as_ref().file_name().map(Candidate::new);
|
let candidate_filename = path.as_ref().file_name().map(Candidate::new);
|
||||||
for (ref glob, ref syntax) in self.mappings.iter().rev() {
|
for (ref glob, ref syntax) in self.mappings.iter().rev() {
|
||||||
|
|
Loading…
Reference in a new issue