Repository: sharkdp/bat (language: rust)

Issue:
/etc/resolv.conf is not highlighted with resolv syntax
<!-- Hey there, thank you for creating an issue! -->

**What version of `bat` are you using?**

latest master


**Describe the bug you encountered:**

Found this while trying to create a syntax test for resolv.conf files:

![image](https://user-images.githubusercontent.com/4209276/104136649-cda14f00-5397-11eb-8331-72ec3100a559.png)


**What did you expect to happen instead?**

`bat` automatically highlighted files called `resolv.conf` with the "resolv" syntax:
```
▶ bat -L | grep resolv        
resolv:resolv.conf
```


---

**Evironment**

#### Software version

bat 0.17.1

#### Operating system

Linux 5.10.5-arch1-1

#### Command-line

```bash
bat resolv.conf --diagnostic 
```

#### Environment variables

```bash
SHELL=/usr/bin/zsh
PAGER=less
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER="sh -c 'col -bx | bat -l man -p'"
```

#### Config file

```
# Use italic text on the terminal (not supported on all terminals)
--italic-text=always

# Syntax mappings
--map-syntax .ignore:"Git Ignore"
--map-syntax .fdignore:"Git Ignore"
--map-syntax '*.ino':"C++"
```

#### Compile time information

- Profile: release
- Target triple: x86_64-unknown-linux-gnu
- Family: unix
- OS: linux
- Architecture: x86_64
- Pointer width: 64
- Endian: little
- CPU features: fxsr,sse,sse2
- Host: x86_64-unknown-linux-gnu

#### Less version

```
> less --version 
less 563 (PCRE regular expressions)
Copyright (C) 1984-2020  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: http://www.greenwoodsoftware.com/less
```



Discussion / hints:
I guess this is due to

https://github.com/sharkdp/bat/blob/30993a8bfc5c9913e7c35d225edba5fee21120f4/src/syntax_mapping.rs#L51-L55

Maybe it somehow shouldn't affect when the syntax definition matches the full filename, or the resolv.conf mapping should be added back in afterwards.

Fix patch:
diff --git a/src/syntax_mapping.rs b/src/syntax_mapping.rs
index fd1e3ec4e6..732d1fd8a7 100644
--- a/src/syntax_mapping.rs
+++ b/src/syntax_mapping.rs
@@ -54,6 +54,11 @@ impl<'a> SyntaxMapping<'a> {
             .insert("*.conf", MappingTarget::MapToUnknown)
             .unwrap();
 
+        // Re-insert a mapping for resolv.conf, see #1510
+        mapping
+            .insert("resolv.conf", MappingTarget::MapTo("resolv"))
+            .unwrap();
+
         for glob in &[
             "/etc/nginx/**/*.conf",
             "/etc/nginx/sites-*/**/*",


Test patch:
diff --git a/tests/syntax-tests/create_highlighted_versions.py b/tests/syntax-tests/create_highlighted_versions.py
index 4319f47a97..75ae9a4d1a 100755
--- a/tests/syntax-tests/create_highlighted_versions.py
+++ b/tests/syntax-tests/create_highlighted_versions.py
@@ -12,7 +12,7 @@
     "--no-config",
     "--style=plain",
     "--color=always",
-    "--theme='1337'",
+    "--theme=default",
     "--italic-text=always",
 ]
 
@@ -41,7 +41,9 @@ def create_highlighted_versions(output_basepath):
     root = os.path.dirname(os.path.abspath(__file__))
     sources = path.join(root, "source", "*")
 
-    for source in glob.glob(path.join(sources, "*")) + glob.glob(path.join(sources, ".*")):
+    for source in glob.glob(path.join(sources, "*")) + glob.glob(
+        path.join(sources, ".*")
+    ):
         try:
             env = os.environ.copy()
             env.pop("PAGER", None)
diff --git a/tests/syntax-tests/highlighted/resolv.conf/resolv.conf b/tests/syntax-tests/highlighted/resolv.conf/resolv.conf
new file mode 100644
index 0000000000..f044856231
--- /dev/null
+++ b/tests/syntax-tests/highlighted/resolv.conf/resolv.conf
@@ -0,0 +1,4 @@
+[38;2;117;113;94m# A comment[0m
+[38;2;249;38;114mdomain[0m[38;2;248;248;242m example.com[0m
+[38;2;249;38;114mnameserver[0m[38;2;248;248;242m 192.168.123.123[0m
+[38;2;249;38;114mnameserver[0m[38;2;248;248;242m aa00::aaaa:0000:1234:abcd[0m
diff --git a/tests/syntax-tests/source/resolv.conf/resolv.conf b/tests/syntax-tests/source/resolv.conf/resolv.conf
new file mode 100644
index 0000000000..def2f2d954
--- /dev/null
+++ b/tests/syntax-tests/source/resolv.conf/resolv.conf
@@ -0,0 +1,4 @@
+# A comment
+domain example.com
+nameserver 192.168.123.123
+nameserver aa00::aaaa:0000:1234:abcd