66
|
1 package lexers
|
|
2
|
|
3 import (
|
|
4 . "github.com/alecthomas/chroma/v2" // nolint
|
|
5 )
|
|
6
|
|
7 // Viml lexer.
|
|
8 var Viml = Register(MustNewLexer(
|
|
9 &Config{
|
|
10 Name: "VimL",
|
|
11 Aliases: []string{"vim"},
|
|
12 Filenames: []string{"*.vim", ".vimrc", ".exrc", ".gvimrc", "_vimrc", "_exrc", "_gvimrc", "vimrc", "gvimrc"},
|
|
13 MimeTypes: []string{"text/x-vim"},
|
|
14 },
|
|
15 vimlRules,
|
|
16 ))
|
|
17
|
|
18 func vimlRules() Rules {
|
|
19 return Rules{
|
|
20 "root": {
|
|
21 {`^([ \t:]*)(py(?:t(?:h(?:o(?:n)?)?)?)?)([ \t]*)(<<)([ \t]*)(.*)((?:\n|.)*)(\6)`, ByGroups(UsingSelf("root"), Keyword, Text, Operator, Text, Text, Using("Python"), Text), nil},
|
|
22 {`^([ \t:]*)(py(?:t(?:h(?:o(?:n)?)?)?)?)([ \t])(.*)`, ByGroups(UsingSelf("root"), Keyword, Text, Using("Python")), nil},
|
|
23 {`^\s*".*`, Comment, nil},
|
|
24 {`[ \t]+`, Text, nil},
|
|
25 {`/(\\\\|\\/|[^\n/])*/`, LiteralStringRegex, nil},
|
|
26 {`"(\\\\|\\"|[^\n"])*"`, LiteralStringDouble, nil},
|
|
27 {`'(''|[^\n'])*'`, LiteralStringSingle, nil},
|
|
28 {`(?<=\s)"[^\-:.%#=*].*`, Comment, nil},
|
|
29 {`-?\d+`, LiteralNumber, nil},
|
|
30 {`#[0-9a-f]{6}`, LiteralNumberHex, nil},
|
|
31 {`^:`, Punctuation, nil},
|
|
32 {`[()<>+=!|,~-]`, Punctuation, nil},
|
|
33 {`\b(let|if|else|endif|elseif|fun|function|endfunction)\b`, Keyword, nil},
|
|
34 {`\b(NONE|bold|italic|underline|dark|light)\b`, NameBuiltin, nil},
|
|
35 {`\b\w+\b`, NameOther, nil},
|
|
36 {`.`, Text, nil},
|
|
37 },
|
|
38 }
|
|
39 }
|