blob: 5a9a2173372a34b2d1be3cb35de50dad106ede7e [file] [log] [blame]
Bram Moolenaarb59ae592022-11-23 23:46:31 +00001" Vim syntax file
2" Language: Mermaid
3" Maintainer: Craig MacEahern <https://github.com/craigmac/vim-mermaid>
4" Filenames: *.mmd
KSR-Yasudaa03647a2023-12-28 03:02:35 +09005" Last Change: 2023 Dec 26
Bram Moolenaarb59ae592022-11-23 23:46:31 +00006
7if exists("b:current_syntax")
8 finish
9endif
10
11let s:cpo_save = &cpo
12set cpo&vim
13
14syntax iskeyword @,48-57,192-255,$,_,-,:
15syntax keyword mermaidKeyword
16 \ _blank
17 \ _self
18 \ _parent
19 \ _top
20 \ ::icon
21 \ accDescr
22 \ accTitle
23 \ actor
24 \ activate
25 \ alt
26 \ and
27 \ as
28 \ autonumber
29 \ branch
30 \ break
31 \ callback
32 \ checkout
33 \ class
34 \ classDef
35 \ classDiagram
36 \ click
37 \ commit
38 \ commitgitGraph
39 \ critical
40 \ dataFormat
41 \ dateFormat
42 \ deactivate
43 \ direction
44 \ element
45 \ else
46 \ end
47 \ erDiagram
48 \ flowchart
49 \ gantt
50 \ gitGraph
51 \ graph
52 \ journey
53 \ link
54 \ LR
55 \ TD
56 \ TB
57 \ RL
58 \ loop
59 \ merge
60 \ mindmap root
61 \ Note
62 \ Note right of
63 \ Note left of
64 \ Note over
65 \ note
66 \ note right of
67 \ note left of
68 \ note over
69 \ opt
70 \ option
71 \ par
72 \ participant
73 \ pie
74 \ rect
75 \ requirement
76 \ rgb
77 \ section
78 \ sequenceDiagram
79 \ state
80 \ stateDiagram
81 \ stateDiagram-v2
82 \ style
83 \ subgraph
84 \ title
85highlight link mermaidKeyword Keyword
86
87syntax match mermaidStatement "|"
Bram Moolenaarb59ae592022-11-23 23:46:31 +000088syntax match mermaidStatement "\~\~\~"
89syntax match mermaidStatement "--"
KSR-Yasudaa03647a2023-12-28 03:02:35 +090090syntax match mermaidStatement "\%(<|\|[<*o]\)\?\%(--\|\.\.\)\%(|>\|[>*o]\)\?"
91syntax match mermaidStatement "-\{2,4}[>ox-]"
92syntax match mermaidStatement "\.-[>ox]"
Bram Moolenaarb59ae592022-11-23 23:46:31 +000093syntax match mermaidStatement "-\."
KSR-Yasudaa03647a2023-12-28 03:02:35 +090094syntax match mermaidStatement "-\.\{1,3}-"
Bram Moolenaarb59ae592022-11-23 23:46:31 +000095syntax match mermaidStatement "=="
KSR-Yasudaa03647a2023-12-28 03:02:35 +090096syntax match mermaidStatement "=\{2,4}[>ox=]"
Bram Moolenaarb59ae592022-11-23 23:46:31 +000097syntax match mermaidStatement "&"
KSR-Yasudaa03647a2023-12-28 03:02:35 +090098syntax match mermaidStatement "--\?[>x)]>\?[+-]\?"
Bram Moolenaarb59ae592022-11-23 23:46:31 +000099syntax match mermaidStatement "x--x"
KSR-Yasudaa03647a2023-12-28 03:02:35 +0900100syntax match mermaidStatement "o--o\?"
101syntax match mermaidStatement "<-->\?"
Bram Moolenaarb59ae592022-11-23 23:46:31 +0000102syntax match mermaidStatement ":::"
Bram Moolenaarb59ae592022-11-23 23:46:31 +0000103syntax match mermaidStatement "||--o{"
104highlight link mermaidStatement Statement
105
KSR-Yasudaa03647a2023-12-28 03:02:35 +0900106" FIXME: This unexpectedly matches flow chart node `id1(text)` or others.
107"syntax match mermaidIdentifier "[\+-]\?\w\+(.*)[\$\*]\?"
108"highlight link mermaidIdentifier Identifier
Bram Moolenaarb59ae592022-11-23 23:46:31 +0000109
KSR-Yasudaa03647a2023-12-28 03:02:35 +0900110syntax match mermaidType "[\+-\#\~]\?\c\%(const\s\+\|\*\s*\)*\%(unsigned\s\+\)\?\%(int\|u\?int\%(8\|16\|32\|64\)_t\|char\|long\|long\s\+long\)\>\%(\s\+const\|\s*[\*&]\)*"
111syntax match mermaidType "[\+-\#\~]\?\c\%(const\s\+\|\*\s*\)*\%(double\|float\|String\|bool\)\>\%(\s\+const\|\s*[\*&]\)*"
Bram Moolenaarb59ae592022-11-23 23:46:31 +0000112syntax match mermaidType "[\+-\#\~]\?\cBigDecimal\>"
113syntax match mermaidType "[\+-\#\~]\?\cList\~.\+\~"
114syntax match mermaidType "<<\w\+>>"
115highlight link mermaidType Type
116
117syntax match mermaidComment "%%.*$"
118highlight link mermaidComment Comment
119
120syntax region mermaidDirective start="%%{" end="\}%%"
121highlight link mermaidDirective PreProc
122
123syntax region mermaidString start=/"/ skip=/\\"/ end=/"/
124highlight link mermaidString String
125
126let b:current_syntax = "mermaid"
127
128let &cpo = s:cpo_save
129unlet s:cpo_save
130
131" vim:set sw=2: