Pierrick Guillaume | 280e5b1 | 2024-05-31 12:00:49 +0200 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: rasi (Rofi Advanced Style Information) |
| 3 | " Maintainer: Pierrick Guillaume <pierguill@gmail.com> |
| 4 | " Last Change: 2024 May 21 |
Eisuke Kawashima | fbbaa6e | 2025-04-16 18:20:59 +0200 | [diff] [blame] | 5 | " 2025 Apr 16 by Vim Project (set 'cpoptions' for line continuation, #17121) |
Pierrick Guillaume | 280e5b1 | 2024-05-31 12:00:49 +0200 | [diff] [blame] | 6 | " |
| 7 | " Syntax support for rasi config file |
| 8 | |
| 9 | " This file is based on syntax defined in rofi-theme man page |
| 10 | " https://man.archlinux.org/man/community/rofi/rofi-theme.5.en |
| 11 | |
| 12 | if exists('b:current_syntax') |
| 13 | finish |
| 14 | endif |
| 15 | let b:current_syntax = 'rasi' |
Eisuke Kawashima | fbbaa6e | 2025-04-16 18:20:59 +0200 | [diff] [blame] | 16 | let s:cpo_save = &cpo |
| 17 | set cpo&vim |
Pierrick Guillaume | 280e5b1 | 2024-05-31 12:00:49 +0200 | [diff] [blame] | 18 | |
| 19 | " String {{{ |
| 20 | syn region rasiString start=+"+ skip=+\\"+ end=+"+ oneline contained |
| 21 | syn match rasiCharacter +L\='[^\\]'+ contained |
| 22 | |
| 23 | syn cluster rasiPropertyVals add=rasiString,rasiCharacter |
| 24 | " }}} |
| 25 | |
| 26 | " Integer/Real {{{ |
| 27 | syn match rasiNumber display contained '[+-]\?\d\+\(\.\d\+\)\?' |
| 28 | |
| 29 | syn cluster rasiPropertyVals add=rasiNumber |
| 30 | " }}} |
| 31 | |
| 32 | " Boolean {{{ |
| 33 | syn keyword rasiBool contained true false |
| 34 | |
| 35 | syn cluster rasiPropertyVals add=rasiBool |
| 36 | " }}} |
| 37 | |
| 38 | " Image {{{ |
| 39 | syn match rasiInvImage display contained 'url([^)]*)' |
| 40 | syn keyword rasiImageK contained url linear-gradient |
| 41 | |
| 42 | syn match rasiImage display contained transparent 'url(\s*"\([^"]\|\\"\)\+"\(\s*,\s*\(none\|both\|width\|height\)\)\?\s*)' contains=rasiImageScale,rasiString,rasiImageK |
| 43 | syn keyword rasiImageScale contained none both width height |
| 44 | |
| 45 | syn match rasiImage display contained transparent 'linear-gradient(\s*\(\(top\|left\|right\|bottom\)\s*,\s*\)\?[^,)]\+\s*\(,\s*[^,)]\+\s*\)\+)' contains=rasiImageDirection,@rasiColors,rasiImageK |
| 46 | syn keyword rasiImageDirection contained top left right bottom |
| 47 | |
| 48 | syn match rasiImage display contained transparent 'linear-gradient(\s*\d\+\(rad\|grad\|deg\)\s*,\s*[^,)]\+\s*\(,\s*[^,)]\+\s*\)\+)' contains=rasiImageUnit,@rasiColor,@rasiInvColor,rasiNumber,rasiImageK |
| 49 | syn match rasiImageUnit display contained '\(rad\|grad\|deg\)\>' |
| 50 | |
| 51 | syn cluster rasiPropertyVals add=rasiInvImage,rasiImage |
| 52 | " }}} |
| 53 | |
| 54 | " Reference {{{ |
| 55 | syn match rasiReference display contained '@[a-zA-Z0-9-]\+' |
| 56 | |
| 57 | syn keyword rasiVarReferenceK contained var |
| 58 | |
| 59 | syn match rasiInvVarReference display contained 'var([^)]*)' |
| 60 | syn match rasiVarReference display contained transparent 'var(\s*[a-zA-Z0-9-]\+\s*,\s*\(\a\+\s*([^)]*)\)\?[^),]*)' contains=rasiVarReferenceK,rasiPropertyIdRef,@rasiPropertyVals |
| 61 | syn match rasiPropertyIdRef display contained '\a[a-zA-Z0-9-]*' |
| 62 | |
| 63 | syn cluster rasiPropertyVals add=rasiReference,rasiInvVarReference,rasiVarReference |
| 64 | " }}} |
| 65 | |
| 66 | " Env variable {{{ |
| 67 | syn match rasiInvEnv display contained '${[^}]*}' |
| 68 | syn match rasiEnv display contained '${\w\+}'hs=s+2,he=e-1 |
| 69 | |
| 70 | syn keyword rasiEnvVarK contained env |
| 71 | |
| 72 | syn match rasiInvEnvVar display contained 'env([^)]*)' |
| 73 | syn match rasiEnvVar display contained transparent 'env(\s*\w\+\s*,\s*\(\a\+([^)]*)\)\?[^),]*)' contains=rasiEnvVarK,rasiEnvRef,@rasiPropertyVals |
| 74 | syn match rasiEnvRef display contained '\a\w*' |
| 75 | |
| 76 | syn cluster rasiPropertyVals add=rasiEnv,rasiInvEnv,rasiInvEnvVar,rasiEnvVar |
| 77 | " }}} |
| 78 | |
| 79 | " Color {{{ |
| 80 | syn keyword rasiColorK contained rgb[a] hsl[a] hwb[a] cmyk |
| 81 | |
| 82 | syn match rasiHexColor display contained '#\x\{3,4}' |
| 83 | syn match rasiHexColor display contained '#\x\{6}' |
| 84 | syn match rasiHexColor display contained '#\x\{8}' |
| 85 | syn match rasiInvHexColor display contained '#\x\{5}\X'he=e-1,me=e-1 |
| 86 | syn match rasiInvHexColor display contained '#\x\{7}\X'he=e-1,me=e-1 |
| 87 | |
| 88 | syn match rasiInvRGBColor display contained 'rgb\(a\)\?([^)]*)' |
| 89 | syn match rasiRGBColor display contained transparent 'rgb\(a\)\?(\s*\d\+\s*\(%\)\?\s*,\(\s*\d\+\s*\(%\)\?\s*\){2}\(,\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\)\?)' contains=rasiColorK,rasiNumber,rasiDistance |
| 90 | |
| 91 | syn match rasiInvHSLColor display contained 'h\(sl\|wb\)\(a\)\?([^)]*)' |
| 92 | syn match rasiHSLColor display contained transparent 'h\(sl\|wb\)\(a\)\?(\s*\d\+\(\.\d*\)\?\(deg\|rad\|grad\|turn\)\?\s*\(,\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\)\{2,3})' contains=rasiColorK,rasiNumber,rasiDistance |
| 93 | |
| 94 | |
| 95 | "this matches doesn't works properly (too long ?) |
| 96 | syn match rasiInvCMYKColor display contained 'cmyk([^)]*)' |
| 97 | syn match rasiCMYKColor display contained transparent 'cmyk(\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\(,\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\)\{3,4})' contains=rasiColorK,rasiNumber,rasiDistance |
| 98 | |
| 99 | syn case ignore |
| 100 | syn keyword rasiNamedColor contained |
| 101 | \ AliceBlue AntiqueWhite Aqua Aquamarine Azure Beige Bisque Black BlanchedAlmond Blue |
| 102 | \ BlueViolet Brown BurlyWood CadetBlue Chartreuse Chocolate Coral CornflowerBlue Cornsilk |
| 103 | \ Crimson Cyan DarkBlue DarkCyan DarkGoldenRod DarkGray DarkGrey DarkGreen DarkKhaki DarkMagenta |
| 104 | \ DarkOliveGreen DarkOrange DarkOrchid DarkRed DarkSalmon DarkSeaGreen Dark SlateBlue |
| 105 | \ DarkSlateGray DarkSlateGrey DarkTurquoise DarkViolet DeepPink DeepSkyBlue DimGray DimGrey |
| 106 | \ DodgerBlue FireBrick FloralWhite ForestGreen Fuchsia Gainsboro GhostWhite Gold GoldenRod |
| 107 | \ Gray Grey Green GreenYellow HoneyDew HotPink IndianRed Indigo Ivory Khaki Lavender |
| 108 | \ LavenderBlush LawnGreen LemonChiffon LightBlue LightCoral LightCyan LightGoldenRodYellow |
| 109 | \ LightGray LightGrey LightGreen LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray |
| 110 | \ LightSlateGrey LightSteelBlue LightYellow Lime LimeGreen Linen Magenta Maroon MediumAquaMarine |
| 111 | \ MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen |
| 112 | \ MediumTurquoise MediumVioletRed MidnightBlue MintCream MistyRose Moccasin NavajoWhite Navy |
| 113 | \ OldLace Olive OliveDrab Orange OrangeRed Orchid PaleGoldenRod PaleGreen PaleTurquoise |
| 114 | \ PaleVioletRed PapayaWhip PeachPuff Peru Pink Plum PowderBlue Purple RebeccaPurple Red |
| 115 | \ RosyBrown RoyalBlue SaddleBrown Salmon SandyBrown SeaGreen SeaShell Sienna Silver SkyBlue |
| 116 | \ SlateBlue SlateGray SlateGrey Snow SpringGreen SteelBlue Tan Teal Thistle Tomato Turquoise |
| 117 | \ Violet Wheat White WhiteSmoke Yellow YellowGreen transparent[] "uses `[]` to escape keyword |
| 118 | |
| 119 | syn cluster rasiColors add=rasiHexColor,rasiRGBColor,rasiHSLColor,rasiCMYKColor,rasiNamedColor |
| 120 | syn cluster rasiColors add=rasiInvHexColor,rasiInvRGBColor,rasiInvHSLColor,rasiInvCMYKColor |
| 121 | |
| 122 | syn cluster rasiPropertyVals add=@rasiColors |
| 123 | " }}} |
| 124 | |
| 125 | " Text-Style {{{ |
| 126 | syn keyword rasiTextStyle contained bold italic underline strikethrough none |
| 127 | |
| 128 | syn cluster rasiPropertyVals add=rasiTextStyle |
| 129 | " }}} |
| 130 | |
| 131 | " Line-Style {{{ |
| 132 | syn keyword rasiLineStyle contained dash solid |
| 133 | |
| 134 | syn cluster rasiPropertyVals add=rasiLineStyle |
| 135 | " }}} |
| 136 | |
| 137 | " Distance {{{ |
| 138 | syn match rasiDistanceUnit display contained '\(px\|em\|ch\|%\|mm\)' |
| 139 | |
| 140 | syn match rasiInvDistance display contained '[+-]\?\d\+\.\d\+\(px\|mm\)' |
| 141 | syn match rasiDistance display contained transparent '[-+]\?\d\+\(px\|mm\)' contains=rasiDistanceUnit,rasiNumber |
| 142 | syn match rasiDistance display contained transparent '[+-]\?\d\+\(\.\d\+\)\?\(em\|ch\|%\)' contains=rasiDistanceUnit,rasiNumber |
| 143 | |
| 144 | syn keyword rasiDistanceCalc contained calc nextgroup=rasiDistanceCalcBody |
| 145 | syn region rasiDistanceCalcBody display contained start=+(+ end=+)+ contains=rasiDistanceCalcOp,rasiDistance,rasiInvDistance |
| 146 | syn match rasiDistanceCalcOp display contained '\(+\|-\|/\|\*\|%\|min\|max\)' |
| 147 | |
| 148 | syn cluster rasiPropertyVals add=rasiInvDistance,rasiDistance,rasiDistanceCalc |
| 149 | " }}} |
| 150 | |
| 151 | " Position {{{ |
| 152 | syn keyword rasiPosition contained center east north west south |
| 153 | |
| 154 | syn cluster rasiPropertyVals add=rasiPosition |
| 155 | " }}} |
| 156 | |
| 157 | " Orientation {{{ |
| 158 | syn keyword rasiOrientation contained horizontal vertical |
| 159 | |
| 160 | syn cluster rasiPropertyVals add=rasiOrientation |
| 161 | " }}} |
| 162 | |
| 163 | " Cursor {{{ |
| 164 | syn keyword rasiCursor contained default pointer text |
| 165 | |
| 166 | syn cluster rasiPropertyVals add=rasiCursor |
| 167 | " }}} |
| 168 | |
| 169 | " Keyword List {{{ |
| 170 | syn region rasiKeywordList contained start=+\[+ end=+\]+ contains=rasiPropertyIdRef |
| 171 | |
| 172 | syn cluster rasiPropertyVals add=rasiKeywordList |
| 173 | " }}} |
| 174 | |
| 175 | " Inherit {{{ |
| 176 | syn keyword rasiInherit contained inherit children |
| 177 | |
| 178 | syn cluster rasiPropertyVals add=rasiInherit |
| 179 | " }}} |
| 180 | |
| 181 | syn match rasiGlobalImport display '^\s*@\(import\|theme\)' nextgroup=rasiString skipwhite |
| 182 | |
| 183 | " Section {{{ |
| 184 | " syn region rasiSection transparent start='^[^{]\+{'me=e-1 end='}' contains=rasiSectionOpenning,rasiSectionContent |
| 185 | syn match rasiSectionOpenning transparent '^[^{]\+{'me=e-1 contains=rasiGlobalSection,rasiWidgetName,rasiGlobalMedia nextgroup=rasiThemeSectionContent |
| 186 | " syn match rasiThemeInnerSectionOpenning transparent '^[^:${]\+{'me=e-1 contains=rasiWidgetName nextgroup=rasiThemeInnerSectionContent contained |
| 187 | |
| 188 | syn match rasiGlobalMedia display contained '^\s*@media' nextgroup=rasiInvMediaBody,rasiMediaBody skipwhite |
| 189 | syn match rasiInvMediaBody display contained '([^)]*)' |
| 190 | syn match rasiMediaBody display contained '(\s*[a-z-]\+\s*:\s*\d\+\(px\|mm\)\?\s*)' contains=rasiMediaK,rasiNumber,rasiDistance |
| 191 | syn keyword rasiMediaK contained min-width max-width min-height max-height min-aspect-ratio max-aspect-ratio monitor-id |
| 192 | |
| 193 | syn match rasiGlobalSection display contained '^*' |
| 194 | syn match rasiWidgetName display contained '[a-zA-Z0-9-]\+' nextgroup=rasiVisibleMod skipwhite |
| 195 | |
| 196 | syn keyword rasiVisibleMod contained normal selected alternate nextgroup=rasiVisibleMod,rasiStateWrapper skipwhite |
| 197 | syn match rasiStateWrapper display contained transparent '\.\(normal\|active\|urgent\)' contains=rasiState |
| 198 | syn keyword rasiState contained normal active urgent |
| 199 | |
| 200 | |
| 201 | syn region rasiThemeSectionContent transparent start="{" end="}" contains=rasiProperty,rasiComment,rasiCommentL,rasiSectionOpenning contained |
| 202 | " syn region rasiThemeInnerSectionContent transparent start="{" end="}" contains=rasiProperty,rasiComment,rasiCommentL,rasiThemeInnerSectionOpenning contained |
| 203 | |
| 204 | syn match rasiProperty transparent '^\s*\S\+\s*:.*;\s*$' keepend contained contains=rasiPropertyId,rasiInvPropertyId,rasiPropertyVal,rasiComment,rasiCommentL |
| 205 | syn match rasiInvPropertyId '^\([^:]\&[^/]\{2}\)*:'me=e-1 contained |
| 206 | syn match rasiPropertyId '^\s*[0-9a-zA-Z-]\+\s*:'me=e-1 contained |
| 207 | syn match rasiInvPropertyVal ':[^;];\s*\S\+\s*$'ms=s+1,hs=s+1 |
| 208 | syn match rasiPropertyVal ':\s*[^;]\+;\s*$'ms=s+1,hs=s+1 contained contains=@rasiPropertyVals |
| 209 | " }}} |
| 210 | |
| 211 | " Comment {{{ |
| 212 | syn cluster rasiCommentGroup contains=rasiTodo,rasiBadContinuation |
| 213 | |
| 214 | syn region rasiCommentL start="//" skip="\\$" end="$" keepend contains=@rasiCommentGroup,@Spell |
| 215 | syn region rasiComment start="/\*" end="\*/" contains=@rasiCommentGroup,rasiCommentStartError,@Spell fold extend |
| 216 | |
| 217 | syn match rasiCommentError display '\*/' |
| 218 | |
| 219 | syn keyword rasiTodo contained TODO FIXME XXX NOTE |
| 220 | |
| 221 | if exists("rasi_minlines") |
| 222 | let b:rasi_minlines = rasi_minlines |
| 223 | else |
| 224 | let b:rasi_minlines = 50 |
| 225 | endif |
| 226 | exec "syn sync ccomment rasiComment minlines=" . b:rasi_minlines |
| 227 | " }}} |
| 228 | |
| 229 | |
| 230 | |
| 231 | " Highlighting: {{{ |
| 232 | hi def link rasiError Error |
| 233 | |
| 234 | hi def link rasiTodo Todo |
| 235 | hi def link rasiComment Comment |
| 236 | hi def link rasiCommentStart rasiComment |
| 237 | hi def link rasiCommentL rasiComment |
| 238 | hi def link rasiCommentError rasiError |
| 239 | |
| 240 | hi def link rasiString String |
| 241 | hi def link rasiNumber Number |
| 242 | hi def link rasiBool Boolean |
| 243 | |
| 244 | hi def link rasiImageK Function |
| 245 | hi def link rasiImageScale Keyword |
| 246 | hi def link rasiImageDirection Keyword |
| 247 | hi def link rasiImageUnit Type |
| 248 | hi def link rasiInvImage rasiError |
| 249 | |
| 250 | hi def link rasiHexColor Number |
| 251 | hi def link rasiColorK Function |
| 252 | hi def link rasiNamedColor Number |
| 253 | hi def link rasiInvColor rasiError |
| 254 | hi def link rasiInvHexColor rasiInvColor |
| 255 | hi def link rasiInvRGBColor rasiInvColor |
| 256 | hi def link rasiInvHSLColor rasiInvColor |
| 257 | hi def link rasiInvCMYKColor rasiInvColor |
| 258 | |
| 259 | hi def link rasiTextStyle Keyword |
| 260 | hi def link rasiLineStyle Keyword |
| 261 | |
| 262 | hi def link rasiDistanceUnit Type |
| 263 | hi def link rasiDistanceCalc Function |
| 264 | hi def link rasiDistanceCalcOp Operator |
| 265 | hi def link rasiInvDistance rasiError |
| 266 | |
| 267 | hi def link rasiPosition Keyword |
| 268 | hi def link rasiOrientation Keyword |
| 269 | hi def link rasiCursor Keyword |
| 270 | |
| 271 | hi def link rasiReference Identifier |
| 272 | hi def link rasiPropertyIdRef Identifier |
| 273 | hi def link rasiVarReferenceK Function |
| 274 | hi def link rasiInvVarReference rasiError |
| 275 | |
| 276 | hi def link rasiEnv Identifier |
| 277 | hi def link rasiEnvRef Identifier |
| 278 | hi def link rasiEnvVarK Function |
| 279 | hi def link rasiInvEnv rasiError |
| 280 | hi def link rasiInvEnvVar rasiError |
| 281 | |
| 282 | hi def link rasiWidgetName StorageClass |
| 283 | hi def link rasiGlobalSection StorageClass |
| 284 | hi def link rasiVisibleMod Type |
| 285 | hi def link rasiState Tag |
| 286 | |
| 287 | hi def link rasiInherit Identifier |
| 288 | |
| 289 | hi def link rasiGlobalImport Include |
| 290 | |
| 291 | hi def link rasiGlobalMedia Preproc |
| 292 | hi def link rasiMediaK Keyword |
| 293 | hi def link rasiInvMediaBody rasiError |
| 294 | |
| 295 | hi def link rasiPropertyId Identifier |
| 296 | hi def link rasiInvProperty rasiError |
| 297 | hi def link rasiInvPropertyId rasiError |
| 298 | hi def link rasiInvPropertyVal rasiError |
| 299 | " }}} |
| 300 | |
Eisuke Kawashima | fbbaa6e | 2025-04-16 18:20:59 +0200 | [diff] [blame] | 301 | let &cpo = s:cpo_save |
| 302 | unlet s:cpo_save |
| 303 | |
Pierrick Guillaume | 280e5b1 | 2024-05-31 12:00:49 +0200 | [diff] [blame] | 304 | " vim:ts=8 |