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