mirror of
https://github.com/alecthomas/chroma.git
synced 2025-01-28 03:29:41 +02:00
Add CMake.
This commit is contained in:
parent
afc6c44415
commit
57c8e08560
@ -9,7 +9,7 @@ var Bash = Register(MustNewLexer(
|
|||||||
&Config{
|
&Config{
|
||||||
Name: "Bash",
|
Name: "Bash",
|
||||||
Aliases: []string{"bash", "sh", "ksh", "zsh", "shell"},
|
Aliases: []string{"bash", "sh", "ksh", "zsh", "shell"},
|
||||||
Filenames: []string{"*.sh", "*.ksh", "*.bash", "*.ebuild", "*.eclass", "*.exheres-0", "*.exlib", "*.zsh", ".bashrc", "bashrc", ".bash_*", "bash_*", "zshrc", ".zshrc", "PKGBUILD"},
|
Filenames: []string{"*.sh", "*.ksh", "*.bash", "*.ebuild", "*.eclass", "*.exheres-0", "*.exlib", "*.zsh", "*.zshrc", ".bashrc", "bashrc", ".bash_*", "bash_*", "zshrc", ".zshrc", "PKGBUILD"},
|
||||||
MimeTypes: []string{"application/x-sh", "application/x-shellscript"},
|
MimeTypes: []string{"application/x-sh", "application/x-shellscript"},
|
||||||
},
|
},
|
||||||
Rules{
|
Rules{
|
||||||
|
43
lexers/cmake.go
Normal file
43
lexers/cmake.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package lexers
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
)
|
||||||
|
|
||||||
|
// Cmake lexer.
|
||||||
|
var Cmake = Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "CMake",
|
||||||
|
Aliases: []string{"cmake"},
|
||||||
|
Filenames: []string{"*.cmake", "CMakeLists.txt"},
|
||||||
|
MimeTypes: []string{"text/x-cmake"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"root": {
|
||||||
|
{`\b(\w+)([ \t]*)(\()`, ByGroups(NameBuiltin, Text, Punctuation), Push("args")},
|
||||||
|
Include("keywords"),
|
||||||
|
Include("ws"),
|
||||||
|
},
|
||||||
|
"args": {
|
||||||
|
{`\(`, Punctuation, Push()},
|
||||||
|
{`\)`, Punctuation, Pop(1)},
|
||||||
|
{`(\$\{)(.+?)(\})`, ByGroups(Operator, NameVariable, Operator), nil},
|
||||||
|
{`(\$ENV\{)(.+?)(\})`, ByGroups(Operator, NameVariable, Operator), nil},
|
||||||
|
{`(\$<)(.+?)(>)`, ByGroups(Operator, NameVariable, Operator), nil},
|
||||||
|
{`(?s)".*?"`, LiteralStringDouble, nil},
|
||||||
|
{`\\\S+`, LiteralString, nil},
|
||||||
|
{`[^)$"# \t\n]+`, LiteralString, nil},
|
||||||
|
{`\n`, Text, nil},
|
||||||
|
Include("keywords"),
|
||||||
|
Include("ws"),
|
||||||
|
},
|
||||||
|
"string": {},
|
||||||
|
"keywords": {
|
||||||
|
{`\b(WIN32|UNIX|APPLE|CYGWIN|BORLAND|MINGW|MSVC|MSVC_IDE|MSVC60|MSVC70|MSVC71|MSVC80|MSVC90)\b`, Keyword, nil},
|
||||||
|
},
|
||||||
|
"ws": {
|
||||||
|
{`[ \t]+`, Text, nil},
|
||||||
|
{`#.*\n`, Comment, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
@ -18,5 +18,6 @@ var SwapOff = Register(chroma.NewStyle("swapoff", map[chroma.TokenType]string{
|
|||||||
chroma.GenericUnderline: "underline",
|
chroma.GenericUnderline: "underline",
|
||||||
chroma.NameTag: "bold",
|
chroma.NameTag: "bold",
|
||||||
chroma.NameAttribute: "#ansiteal",
|
chroma.NameAttribute: "#ansiteal",
|
||||||
|
chroma.NameVariable: "bold",
|
||||||
chroma.Error: "#ansired",
|
chroma.Error: "#ansired",
|
||||||
}))
|
}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user