Skip to content

Commit 14a8aba

Browse files
scopalecthomas
authored andcommitted
feat(lexers): match filenames ignoring trailing .in
The .in suffix is often assiociated with build system input/template files, for example in autotools ones.
1 parent 2bcdf19 commit 14a8aba

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: lexers/internal/api.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import (
1212
)
1313

1414
var (
15-
backupSuffixes = [...]string{
15+
ignoredSuffixes = [...]string{
1616
// Editor backups
1717
"~", ".bak", ".old", ".orig",
18-
// Debian and derivatives apt/dpkg
18+
// Debian and derivatives apt/dpkg backups
1919
".dpkg-dist", ".dpkg-old",
20-
// Red Hat and derivatives rpm
20+
// Red Hat and derivatives rpm backups
2121
".rpmnew", ".rpmorig", ".rpmsave",
22+
// Build system input/template files
23+
".in",
2224
}
2325
)
2426

@@ -105,7 +107,7 @@ func Match(filename string) chroma.Lexer {
105107
if fnmatch.Match(glob, filename, 0) {
106108
matched = append(matched, lexer)
107109
} else {
108-
for _, suf := range &backupSuffixes {
110+
for _, suf := range &ignoredSuffixes {
109111
if fnmatch.Match(glob+suf, filename, 0) {
110112
matched = append(matched, lexer)
111113
break
@@ -126,7 +128,7 @@ func Match(filename string) chroma.Lexer {
126128
if fnmatch.Match(glob, filename, 0) {
127129
matched = append(matched, lexer)
128130
} else {
129-
for _, suf := range &backupSuffixes {
131+
for _, suf := range &ignoredSuffixes {
130132
if fnmatch.Match(glob+suf, filename, 0) {
131133
matched = append(matched, lexer)
132134
break

0 commit comments

Comments
 (0)