20753
|
1 " Vim syntax file
|
|
2 " Language: Elm
|
|
3 " Maintainer: Andreas Scharf <as@99n.de>
|
|
4 " Original Author: Joseph Hager <ajhager@gmail.com>
|
|
5 " Copyright: Joseph Hager <ajhager@gmail.com>
|
|
6 " License: BSD3
|
|
7 " Latest Revision: 2020-05-29
|
|
8
|
|
9 if exists('b:current_syntax')
|
|
10 finish
|
|
11 endif
|
|
12
|
|
13 " Keywords
|
|
14 syn keyword elmConditional else if of then case
|
|
15 syn keyword elmAlias alias
|
|
16 syn keyword elmTypedef contained type port
|
|
17 syn keyword elmImport exposing as import module where
|
|
18
|
|
19 " Operators
|
|
20 " elm/core
|
|
21 syn match elmOperator contained "\(<|\||>\|||\|&&\|==\|/=\|<=\|>=\|++\|::\|+\|-\|*\|/\|//\|^\|<>\|>>\|<<\|<\|>\|%\)"
|
|
22 " elm/parser
|
|
23 syn match elmOperator contained "\(|.\||=\)"
|
|
24 " elm/url
|
|
25 syn match elmOperator contained "\(</>\|<?>\)"
|
|
26
|
|
27 " Types
|
|
28 syn match elmType "\<[A-Z][0-9A-Za-z_-]*"
|
|
29 syn keyword elmNumberType number
|
|
30
|
|
31 " Modules
|
|
32 syn match elmModule "\<\([A-Z][0-9A-Za-z_'-\.]*\)\+\.[A-Za-z]"me=e-2
|
|
33 syn match elmModule "^\(module\|import\)\s\+[A-Z][0-9A-Za-z_'-\.]*\(\s\+as\s\+[A-Z][0-9A-Za-z_'-\.]*\)\?\(\s\+exposing\)\?" contains=elmImport
|
|
34
|
|
35 " Delimiters
|
|
36 syn match elmDelimiter "[,;]"
|
|
37 syn match elmBraces "[()[\]{}]"
|
|
38
|
|
39 " Functions
|
|
40 syn match elmTupleFunction "\((,\+)\)"
|
|
41
|
|
42 " Comments
|
|
43 syn keyword elmTodo TODO FIXME XXX contained
|
|
44 syn match elmLineComment "--.*" contains=elmTodo,@spell
|
|
45 syn region elmComment matchgroup=elmComment start="{-|\=" end="-}" contains=elmTodo,elmComment,@spell fold
|
|
46
|
|
47 " Strings
|
|
48 syn match elmStringEscape "\\u[0-9a-fA-F]\{4}" contained
|
|
49 syn match elmStringEscape "\\[nrfvbt\\\"]" contained
|
|
50 syn region elmString start="\"" skip="\\\"" end="\"" contains=elmStringEscape,@spell
|
|
51 syn region elmTripleString start="\"\"\"" skip="\\\"" end="\"\"\"" contains=elmStringEscape,@spell
|
|
52 syn match elmChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'"
|
|
53
|
|
54 " Lambda
|
|
55 syn region elmLambdaFunc start="\\"hs=s+1 end="->"he=e-2
|
|
56
|
|
57 " Debug
|
|
58 syn match elmDebug "Debug.\(log\|todo\|toString\)"
|
|
59
|
|
60 " Numbers
|
|
61 syn match elmInt "-\?\<\d\+\>"
|
|
62 syn match elmFloat "-\?\(\<\d\+\.\d\+\>\)"
|
|
63
|
|
64 " Identifiers
|
|
65 syn match elmTopLevelDecl "^\s*[a-zA-Z][a-zA-z0-9_]*\('\)*\s\+:\(\r\n\|\r\|\n\|\s\)\+" contains=elmOperator
|
|
66 syn match elmFuncName /^\l\w*/
|
|
67
|
|
68 " Folding
|
|
69 syn region elmTopLevelTypedef start="type" end="\n\(\n\n\)\@=" contains=ALL fold
|
|
70 syn region elmTopLevelFunction start="^[a-zA-Z].\+\n[a-zA-Z].\+=" end="^\(\n\+\)\@=" contains=ALL fold
|
|
71 syn region elmCaseBlock matchgroup=elmCaseBlockDefinition start="^\z\(\s\+\)\<case\>" end="^\z1\@!\W\@=" end="\(\n\n\z1\@!\)\@=" end="\n\z1\@!\(\n\n\)\@=" contains=ALL fold
|
|
72 syn region elmCaseItemBlock start="^\z\(\s\+\).\+->$" end="^\z1\@!\W\@=" end="\(\n\n\z1\@!\)\@=" end="\(\n\z1\S\)\@=" contains=ALL fold
|
|
73 syn region elmLetBlock matchgroup=elmLetBlockDefinition start="\<let\>" end="\<in\>" contains=ALL fold
|
|
74
|
|
75 hi def link elmFuncName Function
|
|
76 hi def link elmCaseBlockDefinition Conditional
|
|
77 hi def link elmCaseBlockItemDefinition Conditional
|
|
78 hi def link elmLetBlockDefinition TypeDef
|
|
79 hi def link elmTopLevelDecl Function
|
|
80 hi def link elmTupleFunction Normal
|
|
81 hi def link elmTodo Todo
|
|
82 hi def link elmComment Comment
|
|
83 hi def link elmLineComment Comment
|
|
84 hi def link elmString String
|
|
85 hi def link elmTripleString String
|
|
86 hi def link elmChar String
|
|
87 hi def link elmStringEscape Special
|
|
88 hi def link elmInt Number
|
|
89 hi def link elmFloat Float
|
|
90 hi def link elmDelimiter Delimiter
|
|
91 hi def link elmBraces Delimiter
|
|
92 hi def link elmTypedef TypeDef
|
|
93 hi def link elmImport Include
|
|
94 hi def link elmConditional Conditional
|
|
95 hi def link elmAlias Delimiter
|
|
96 hi def link elmOperator Operator
|
|
97 hi def link elmType Type
|
|
98 hi def link elmNumberType Identifier
|
|
99 hi def link elmLambdaFunc Function
|
|
100 hi def link elmDebug Debug
|
|
101 hi def link elmModule Type
|
|
102
|
|
103 syn sync minlines=500
|
|
104
|
|
105 let b:current_syntax = 'elm'
|