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