Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Mermaid |
| 3 | " Maintainer: Craig MacEahern <https://github.com/craigmac/vim-mermaid> |
| 4 | " Filenames: *.mmd |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 5 | " Last Change: 2023 Dec 26 |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 6 | |
| 7 | if exists("b:current_syntax") |
| 8 | finish |
| 9 | endif |
| 10 | |
| 11 | let s:cpo_save = &cpo |
| 12 | set cpo&vim |
| 13 | |
| 14 | syntax iskeyword @,48-57,192-255,$,_,-,: |
| 15 | syntax 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 |
| 85 | highlight link mermaidKeyword Keyword |
| 86 | |
| 87 | syntax match mermaidStatement "|" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 88 | syntax match mermaidStatement "\~\~\~" |
| 89 | syntax match mermaidStatement "--" |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 90 | syntax match mermaidStatement "\%(<|\|[<*o]\)\?\%(--\|\.\.\)\%(|>\|[>*o]\)\?" |
| 91 | syntax match mermaidStatement "-\{2,4}[>ox-]" |
| 92 | syntax match mermaidStatement "\.-[>ox]" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 93 | syntax match mermaidStatement "-\." |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 94 | syntax match mermaidStatement "-\.\{1,3}-" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 95 | syntax match mermaidStatement "==" |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 96 | syntax match mermaidStatement "=\{2,4}[>ox=]" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 97 | syntax match mermaidStatement "&" |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 98 | syntax match mermaidStatement "--\?[>x)]>\?[+-]\?" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 99 | syntax match mermaidStatement "x--x" |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 100 | syntax match mermaidStatement "o--o\?" |
| 101 | syntax match mermaidStatement "<-->\?" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 102 | syntax match mermaidStatement ":::" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 103 | syntax match mermaidStatement "||--o{" |
| 104 | highlight link mermaidStatement Statement |
| 105 | |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 106 | " FIXME: This unexpectedly matches flow chart node `id1(text)` or others. |
| 107 | "syntax match mermaidIdentifier "[\+-]\?\w\+(.*)[\$\*]\?" |
| 108 | "highlight link mermaidIdentifier Identifier |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 109 | |
KSR-Yasuda | a03647a | 2023-12-28 03:02:35 +0900 | [diff] [blame] | 110 | syntax match mermaidType "[\+-\#\~]\?\c\%(const\s\+\|\*\s*\)*\%(unsigned\s\+\)\?\%(int\|u\?int\%(8\|16\|32\|64\)_t\|char\|long\|long\s\+long\)\>\%(\s\+const\|\s*[\*&]\)*" |
| 111 | syntax match mermaidType "[\+-\#\~]\?\c\%(const\s\+\|\*\s*\)*\%(double\|float\|String\|bool\)\>\%(\s\+const\|\s*[\*&]\)*" |
Bram Moolenaar | b59ae59 | 2022-11-23 23:46:31 +0000 | [diff] [blame] | 112 | syntax match mermaidType "[\+-\#\~]\?\cBigDecimal\>" |
| 113 | syntax match mermaidType "[\+-\#\~]\?\cList\~.\+\~" |
| 114 | syntax match mermaidType "<<\w\+>>" |
| 115 | highlight link mermaidType Type |
| 116 | |
| 117 | syntax match mermaidComment "%%.*$" |
| 118 | highlight link mermaidComment Comment |
| 119 | |
| 120 | syntax region mermaidDirective start="%%{" end="\}%%" |
| 121 | highlight link mermaidDirective PreProc |
| 122 | |
| 123 | syntax region mermaidString start=/"/ skip=/\\"/ end=/"/ |
| 124 | highlight link mermaidString String |
| 125 | |
| 126 | let b:current_syntax = "mermaid" |
| 127 | |
| 128 | let &cpo = s:cpo_save |
| 129 | unlet s:cpo_save |
| 130 | |
| 131 | " vim:set sw=2: |