mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-02 19:32:25 +01:00
Introduce MapExtensionToUnknown MappingTarget (#1889)
Co-authored-by: Martin Nordholts <enselic@gmail.com>
This commit is contained in:
@@ -6,8 +6,21 @@ use globset::{Candidate, GlobBuilder, GlobMatcher};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum MappingTarget<'a> {
|
||||
/// For mapping a path to a specific syntax.
|
||||
MapTo(&'a str),
|
||||
|
||||
/// For mapping a path (typically an extension-less file name) to an unknown
|
||||
/// syntax. This typically means later using the contents of the first line
|
||||
/// of the file to determine what syntax to use.
|
||||
MapToUnknown,
|
||||
|
||||
/// For mapping a file extension (e.g. `*.conf`) to an unknown syntax. This
|
||||
/// typically means later using the contents of the first line of the file
|
||||
/// to determine what syntax to use. However, if a syntax handles a file
|
||||
/// name that happens to have the given file extension (e.g. `resolv.conf`),
|
||||
/// then that association will have higher precedence, and the mapping will
|
||||
/// be ignored.
|
||||
MapExtensionToUnknown,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -54,12 +67,7 @@ impl<'a> SyntaxMapping<'a> {
|
||||
// Nginx and Apache syntax files both want to style all ".conf" files
|
||||
// see #1131 and #1137
|
||||
mapping
|
||||
.insert("*.conf", MappingTarget::MapToUnknown)
|
||||
.unwrap();
|
||||
|
||||
// Re-insert a mapping for resolv.conf, see #1510
|
||||
mapping
|
||||
.insert("resolv.conf", MappingTarget::MapTo("resolv"))
|
||||
.insert("*.conf", MappingTarget::MapExtensionToUnknown)
|
||||
.unwrap();
|
||||
|
||||
for glob in &[
|
||||
|
Reference in New Issue
Block a user