summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/alecthomas/chroma/lexers/b/bash.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/alecthomas/chroma/lexers/b/bash.go')
-rw-r--r--vendor/github.com/alecthomas/chroma/lexers/b/bash.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/vendor/github.com/alecthomas/chroma/lexers/b/bash.go b/vendor/github.com/alecthomas/chroma/lexers/b/bash.go
index 7eac38ef56..34b1e222d3 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/b/bash.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/b/bash.go
@@ -7,17 +7,27 @@ import (
"github.com/alecthomas/chroma/lexers/internal"
)
+// TODO(moorereason): can this be factored away?
var bashAnalyserRe = regexp.MustCompile(`(?m)^#!.*/bin/(?:env |)(?:bash|zsh|sh|ksh)`)
// Bash lexer.
-var Bash = internal.Register(MustNewLexer(
+var Bash = internal.Register(MustNewLazyLexer(
&Config{
Name: "Bash",
Aliases: []string{"bash", "sh", "ksh", "zsh", "shell"},
Filenames: []string{"*.sh", "*.ksh", "*.bash", "*.ebuild", "*.eclass", ".env", "*.env", "*.exheres-0", "*.exlib", "*.zsh", "*.zshrc", ".bashrc", "bashrc", ".bash_*", "bash_*", "zshrc", ".zshrc", "PKGBUILD"},
MimeTypes: []string{"application/x-sh", "application/x-shellscript"},
},
- Rules{
+ bashRules,
+).SetAnalyser(func(text string) float32 {
+ if bashAnalyserRe.FindString(text) != "" {
+ return 1.0
+ }
+ return 0.0
+}))
+
+func bashRules() Rules {
+ return Rules{
"root": {
Include("basic"),
{"`", LiteralStringBacktick, Push("backticks")},
@@ -86,10 +96,5 @@ var Bash = internal.Register(MustNewLexer(
{"`", LiteralStringBacktick, Pop(1)},
Include("root"),
},
- },
-).SetAnalyser(func(text string) float32 {
- if bashAnalyserRe.FindString(text) != "" {
- return 1.0
}
- return 0.0
-}))
+}