aboutsummaryrefslogtreecommitdiff
path: root/micro-vim/syntax/micro.vim
blob: f62057907ce7f4543c46564ac0fd66ee0d53f147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
if exists("b:current_syntax")
    finish
endif

let s:cpo_save = &cpo
set cpo&vim

syn clear
syn sync fromstart

syn match microNumber             /\<[0-9]\d*\>/

syn match microEscapeHex          /\\x\x{2}/ transparent contained
syn match microEscapeChar         /\\[nt\\']/ transparent contained
syn match microEscapeString       /\\[nt\\"]/ transparent contained

syn cluster microCharacterGroup   contains=microEscapeChar,microEscapeHex
syn region microCharacter         start=/'/ skip=/\\\\\|\\'/ end=/'/ contains=@microCharacterGroup

syn cluster microStringGroup      contains=microEscapeString,microEscapeHex
syn region microString            start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=@Spell,microStringGroup

syn keyword microConditional      if else continue break
syn keyword microRepeat           for in
syn keyword microType             number bool string func
syn keyword microBoolean          true false
syn keyword microKeyword          len
syn keyword microStatement        return nextgroup=microTagE skipwhite skipempty

syn match microTagE               /!?/ display contained

"" this is probably not correct
syn match microOperator           display "?\|+\|-\|/\|*\|=\|=\|\^\|&\||\|!\|!=\|>\|>=\|<\|<=\|\~\|%"
syn match microOperator           display "&&\|||"

syn keyword microKeyword          def nextgroup=microFuncName skipwhite skipempty
syn match microFuncName           /[_a-zA-Z][_a-zA-Z0-9]*/ nextgroup=microFuncParams display contained
syn region microFuncParams        start=/(/ end=/)/ contains=microVarIdent,microNumber,microChar nextgroup=microVarType,microVarArray skipwhite contained

syn match mucroPropStart          /\./ nextgroup=microProp skipwhite
syn match microProp               /[_a-zA-Z][_a-zA-Z0-9]*/ display contained

syn keyword microKeyword          var nextgroup=microVarIdent skipwhite skipempty
syn keyword microKeyword          const nextgroup=microVarIdent skipwhite skipempty
syn match microVarIdent           /[_a-zA-Z][_a-zA-Z0-9]*/ nextgroup=microVarType,microVarArray skipwhite
syn match microVarArray           /\[[0-9]*\]/ nextgroup=microVarType transparent contained skipwhite
syn match microVarType            /[_a-zA-Z][_a-zA-Z0-9]*/ display contained

syn match microCall               /[_a-zA-Z][_a-zA-Z0-9]*(/he=e-1,me=e-1

syn region microIndex             start=/\[/ end=/\]/ contains=microNumber,microChar,microIndexIdent,microIndexCall
syn match microIndexIdent         /[_a-zA-Z][_a-zA-Z0-9]*/ display contained
syn match microIndexCall          /[_a-zA-Z][_a-zA-Z0-9]*(/he=e-1,me=e-1 display contained

syn keyword microBuiltin          println panic

syn region microBlock             start="{" end="}" transparent fold

syn keyword microCommentTodo      TODO FIXME XXX BUG contained
syn match   microLineComment      "\/\/.*" contains=@Spell,microCommentTodo

hi def link microLineComment      Comment
hi def link microCommentTodo      Todo
hi def link microNumber           Number
hi def link microCharacter        Character
hi def link microString           String
hi def link microStrEmbeddedQuote String
hi def link microConditional      Conditional
hi def link microRepeat           Repeat
hi def link microOperator         Operator
hi def link microType             Type
hi def link microVarType          Type
hi def link microBoolean          Boolean
hi def link microKeyword          Keyword
hi def link microStatement        Statement
hi def link microTagE             Keyword

hi def link microBuiltin          Function
hi def link microFuncName         Function
hi def link microCall             Function
hi def link microProp             Identifier

hi def link microIndexIdent       Number
hi def link microIndexCall        Function

let b:current_syntax = "micro"

let &cpo = s:cpo_save
unlet s:cpo_save