mirror of
https://github.com/alecthomas/chroma.git
synced 2025-04-09 07:13:52 +02:00
Add NewLazyLexer and MustNewLazyLexer which accept a function that returns the rules for the lexer. This allows us to defer the rules definitions until they're needed. Lexers in a, g, s, and x packages have been updated to use the new lazy lexer.
31 lines
719 B
Go
31 lines
719 B
Go
package p
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Pacmanconf lexer.
|
|
var Pacmanconf = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "PacmanConf",
|
|
Aliases: []string{"pacmanconf"},
|
|
Filenames: []string{"pacman.conf"},
|
|
MimeTypes: []string{},
|
|
},
|
|
pacmanconfRules,
|
|
))
|
|
|
|
func pacmanconfRules() Rules {
|
|
return Rules{
|
|
"root": {
|
|
{`#.*$`, CommentSingle, nil},
|
|
{`^\s*\[.*?\]\s*$`, Keyword, nil},
|
|
{`(\w+)(\s*)(=)`, ByGroups(NameAttribute, Text, Operator), nil},
|
|
{`^(\s*)(\w+)(\s*)$`, ByGroups(Text, NameAttribute, Text), nil},
|
|
{Words(``, `\b`, `$repo`, `$arch`, `%o`, `%u`), NameVariable, nil},
|
|
{`.`, Text, nil},
|
|
},
|
|
}
|
|
}
|