vim-polyglot/syntax/elm.vim

86 lines
2.9 KiB
VimL
Raw Normal View History

if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'elm') != -1
finish
endif
2017-09-27 14:52:13 -04:00
" syntax highlighting for Elm (http://elm-lang.org/)
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
if exists('b:current_syntax')
2015-12-06 05:53:26 -05:00
finish
endif
" Keywords
2018-06-05 16:50:18 -04:00
syn keyword elmConditional else if of then
2017-09-27 14:52:13 -04:00
syn keyword elmAlias alias
2018-06-05 16:50:18 -04:00
syn keyword elmTypedef contained type port
2017-09-27 14:52:13 -04:00
syn keyword elmImport exposing as import module where
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
" Operators
2018-06-05 16:50:18 -04:00
syn match elmOperator contained "\([-!#$%`&\*\+./<=>\?@\\^|~:]\|\<_\>\)"
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
" Types
syn match elmType "\<[A-Z][0-9A-Za-z_'-]*"
syn keyword elmNumberType number
" Delimiters
syn match elmDelimiter "[,;]"
syn match elmBraces "[()[\]{}]"
" Functions
syn match elmTupleFunction "\((,\+)\)"
2015-12-06 05:53:26 -05:00
" Comments
2017-09-27 14:52:13 -04:00
syn keyword elmTodo TODO FIXME XXX contained
2015-12-06 05:53:26 -05:00
syn match elmLineComment "--.*" contains=elmTodo,@spell
2018-06-05 16:50:18 -04:00
syn region elmComment matchgroup=elmComment start="{-|\=" end="-}" contains=elmTodo,elmComment,@spell fold
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
" Strings
2015-12-06 05:53:26 -05:00
syn match elmStringEscape "\\u[0-9a-fA-F]\{4}" contained
syn match elmStringEscape "\\[nrfvbt\\\"]" contained
2017-09-27 14:52:13 -04:00
syn region elmString start="\"" skip="\\\"" end="\"" contains=elmStringEscape,@spell
syn region elmTripleString start="\"\"\"" skip="\\\"" end="\"\"\"" contains=elmStringEscape,@spell
syn match elmChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'"
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
" Numbers
syn match elmInt "-\?\<\d\+\>\|0[xX][0-9a-fA-F]\+\>"
syn match elmFloat "\(\<\d\+\.\d\+\>\)"
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
" Identifiers
2018-07-08 09:16:28 -04:00
syn match elmTopLevelDecl "^\s*[a-zA-Z][a-zA-z0-9_]*\('\)*\s\+:\(\r\n\|\r\|\n\|\s\)\+" contains=elmOperator
2019-04-23 05:32:40 -04:00
syn match elmFuncName /^\l\w*/
2017-09-27 14:52:13 -04:00
2018-06-05 16:50:18 -04:00
" Folding
syn region elmTopLevelTypedef start="type" end="\n\(\n\n\)\@=" contains=ALL fold
syn region elmTopLevelFunction start="^[a-zA-Z].\+\n[a-zA-Z].\+=" end="^\(\n\+\)\@=" contains=ALL fold
syn region elmCaseBlock matchgroup=elmCaseBlockDefinition start="^\z\(\s\+\)\<case\>" end="^\z1\@!\W\@=" end="\(\n\n\z1\@!\)\@=" end="\n\z1\@!\(\n\n\)\@=" contains=ALL fold
syn region elmCaseItemBlock start="^\z\(\s\+\).\+->$" end="^\z1\@!\W\@=" end="\(\n\n\z1\@!\)\@=" end="\(\n\z1\S\)\@=" contains=ALL fold
syn region elmLetBlock matchgroup=elmLetBlockDefinition start="\<let\>" end="\<in\>" contains=ALL fold
2019-04-23 05:32:40 -04:00
hi def link elmFuncName Function
2018-06-05 16:50:18 -04:00
hi def link elmCaseBlockDefinition Conditional
hi def link elmCaseBlockItemDefinition Conditional
hi def link elmLetBlockDefinition TypeDef
2017-09-27 14:52:13 -04:00
hi def link elmTopLevelDecl Function
hi def link elmTupleFunction Normal
hi def link elmTodo Todo
hi def link elmComment Comment
hi def link elmLineComment Comment
hi def link elmString String
hi def link elmTripleString String
hi def link elmChar String
hi def link elmStringEscape Special
hi def link elmInt Number
hi def link elmFloat Float
hi def link elmDelimiter Delimiter
hi def link elmBraces Delimiter
hi def link elmTypedef TypeDef
hi def link elmImport Include
hi def link elmConditional Conditional
hi def link elmAlias Delimiter
hi def link elmOperator Operator
hi def link elmType Identifier
hi def link elmNumberType Identifier
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
syn sync minlines=500
2015-12-06 05:53:26 -05:00
2017-09-27 14:52:13 -04:00
let b:current_syntax = 'elm'