You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

327 lines
15KB

  1. %YAML 1.2
  2. ---
  3. # http://www.sublimetext.com/docs/3/syntax.html
  4. name: LESS
  5. comment: LESS
  6. file_extensions:
  7. - less
  8. scope: source.less
  9. contexts:
  10. main:
  11. - include: comment-block
  12. - include: comment-line
  13. - include: less-at-rules
  14. - include: less-declarations
  15. - include: less-variables
  16. - include: less-functions
  17. - include: string-double
  18. - include: string-single
  19. - include: selector
  20. - include: rule-list
  21. - include: less-operators
  22. - include: less-parameters
  23. - include: numeric-values
  24. color-values:
  25. - match: \b(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow)\b
  26. comment: http://www.w3.org/TR/CSS21/syndata.html#value-def-color
  27. scope: support.constant.color.w3c-standard-color-name.css
  28. - match: \b(aliceblue|antiquewhite|aquamarine|azure|beige|bisque|blanchedalmond|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|gainsboro|ghostwhite|gold|goldenrod|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|limegreen|linen|magenta|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|oldlace|olivedrab|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|thistle|tomato|turquoise|violet|wheat|whitesmoke|yellowgreen)\b
  29. comment: "These colours are mostly recognised but will not validate. ref: http://www.w3schools.com/css/css_colornames.asp"
  30. scope: support.constant.color.non-standard
  31. - match: (hsla?|rgba?)\s*(\()
  32. captures:
  33. 1: support.function.misc.css
  34. 2: punctuation.section.function.css
  35. push:
  36. - match: (\))
  37. captures:
  38. 1: punctuation.section.function.css
  39. pop: true
  40. - match: '(?x)\b(0*((1?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))\s*,\s*){2}(0*((1?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))\b)(\s*,\s*((0?\.[0-9]+)|[0-1]))?'
  41. scope: constant.other.color.rgb-value.css
  42. - match: '\b([0-9]{1,2}|100)\s*%,\s*([0-9]{1,2}|100)\s*%,\s*([0-9]{1,2}|100)\s*%'
  43. scope: constant.other.color.rgb-percentage.css
  44. - include: numeric-values
  45. comment-block:
  46. - match: /\*
  47. captures:
  48. 0: punctuation.definition.comment.css
  49. push:
  50. - meta_scope: comment.block.css
  51. - match: \*/
  52. captures:
  53. 0: punctuation.definition.comment.css
  54. pop: true
  55. comment-line:
  56. - match: //
  57. captures:
  58. 0: punctuation.definition.comment.css
  59. push:
  60. - meta_scope: comment.line.double-slash.less
  61. - match: $\n?
  62. captures:
  63. 0: punctuation.definition.comment.css
  64. pop: true
  65. less-at-rules:
  66. - match: ^\s*((@)(?:-(?:webkit|moz|o)-)?(charset|import|namespace|media|page|font-face|keyframes|supports|document)\b)
  67. scope: meta.at-rule.css
  68. captures:
  69. 1: keyword.control.at-rule.css
  70. 2: punctuation.definition.keyword.css
  71. less-data-uri:
  72. - match: (url)(\()(data:)
  73. captures:
  74. 1: support.function.misc.css
  75. 2: punctuation.section.function.css
  76. 3: parameter.less.data-uri comment markup.raw
  77. push:
  78. - meta_content_scope: parameter.less.data-uri comment markup.raw
  79. - match: (\))
  80. captures:
  81. 1: punctuation.section.function.css
  82. pop: true
  83. - match: (url)(\()("data:)
  84. captures:
  85. 1: support.function.misc.css
  86. 2: punctuation.section.function.css
  87. 3: parameter.less.data-uri comment markup.raw
  88. push:
  89. - meta_content_scope: parameter.less.data-uri comment markup.raw
  90. - match: (?<=")(\))
  91. captures:
  92. 1: punctuation.section.function.css
  93. pop: true
  94. - match: (url)(\()('data:)
  95. captures:
  96. 1: support.function.misc.css
  97. 2: punctuation.section.function.css
  98. 3: parameter.less.data-uri comment markup.raw
  99. push:
  100. - meta_content_scope: parameter.less.data-uri comment markup.raw
  101. - match: (?<=\')(\))
  102. captures:
  103. 1: punctuation.section.function.css
  104. pop: true
  105. less-declarations:
  106. - match: '(?>@[a-zA-Z0-9_-][\w-]*+)(?!:)'
  107. scope: variable.other.less
  108. - match: '@[a-zA-Z0-9_-][\w-]*'
  109. scope: variable.declaration.less
  110. less-functions:
  111. - match: '([%a-zA-Z\-\_\d]*)(?=\()'
  112. scope: support.function.less
  113. - match: '([\.#](?![0-9])[a-zA-Z0-9_-]+(?=\())'
  114. captures:
  115. 1: entity.other.attribute-name.class.css entity.other.less.mixin
  116. less-operators:
  117. - match: /|!important|$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|(?<!\()/=|%=|\+=|\-=|&=|when\b|and\b|not\b
  118. scope: keyword.operator.less
  119. less-parameters:
  120. - match: '\(|(}\s*,)'
  121. push:
  122. - meta_scope: parameter.less
  123. - match: '\)|{'
  124. pop: true
  125. - include: color-values
  126. - include: less-parameters
  127. - include: less-functions
  128. - include: numeric-values
  129. - include: string-double
  130. - include: string-single
  131. - include: less-variables
  132. - match: '(?:\:/)?[\/\.a-zA-Z0-9_\-]*'
  133. scope: variable.parameter.misc.css
  134. - include: less-operators
  135. less-variables:
  136. - match: '@[a-zA-Z0-9_-][\w-]*'
  137. scope: variable.other.less
  138. - match: '@{[a-zA-Z0-9_-][\w-]*}'
  139. scope: variable.interpolation.less
  140. - match: "`"
  141. push:
  142. - meta_scope: comment markup.raw
  143. - match: "`"
  144. pop: true
  145. - match: (~)`
  146. captures:
  147. 1: keyword.operator.less
  148. push:
  149. - meta_scope: comment markup.raw
  150. - match: "`"
  151. pop: true
  152. - match: (~)"
  153. captures:
  154. 1: keyword.operator.less
  155. push:
  156. - meta_scope: string.quoted.double.css comment markup.raw
  157. - match: '"'
  158. pop: true
  159. - match: (~)'
  160. captures:
  161. 1: keyword.operator.less
  162. push:
  163. - meta_scope: string.quoted.single.css comment markup.raw
  164. - match: "'"
  165. pop: true
  166. numeric-values:
  167. - match: '(#)([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b'
  168. scope: constant.other.color.rgb-value.css
  169. captures:
  170. 1: punctuation.definition.constant.css
  171. - match: '(?x)(?:-|\+)?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+))((?:px|pt|ch|cm|mm|in|r?em|ex|pc|deg|g?rad|dpi|dpcm|ms|s)\b|%)?'
  172. scope: constant.numeric.css
  173. captures:
  174. 1: keyword.other.unit.css
  175. property-names:
  176. - match: "(?<![-a-z])(?=[-a-z])"
  177. push:
  178. - meta_scope: support.type.property-name.css
  179. - match: "$|(?![-a-z])"
  180. pop: true
  181. - match: \b(word)\b
  182. scope: support.type.property-name.css
  183. property-values:
  184. - include: less-variables
  185. - include: less-data-uri
  186. - include: less-functions
  187. - include: less-operators
  188. - include: color-values
  189. - include: numeric-values
  190. - include: less-parameters
  191. - match: \b(absolute|all(-scroll)?|always|subpixel-antialiased|antialiased|armenian|auto|avoid|baseline|below|bidi-override|block|bold|bolder|border-box|both|bottom|break-all|break-word|capitalize|center|char|circle|cjk-ideographic|content-box|col-resize|collapse|crosshair|dashed|decimal-leading-zero|decimal|default|disabled|disc|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ellipsis|fixed|geometricPrecision|georgian|groove|hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|inactive|inherit|inline-block|inline|inset|inside|inter-ideograph|inter-word|italic|justify|katakana-iroha|katakana|keep-all|left|lighter|line-edge|line-through|line|list-item|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|nw-resize|none|normal|not-allowed|nowrap|oblique|optimize(Legibility|Quality|Speed)|outset|outside|overline|pointer|pre(-(wrap|line))?|progress|relative|repeat-x|repeat-y|repeat|right|ridge|row-resize|rtl|s-resize|scroll|se-resize|separate|small-caps|solid|square|static|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table|tb-rl|text-bottom|text-top|textfield|text|thick|thin|top|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|vertical(-(ideographic|text))?|visible(Painted|Fill|Stroke)?|w-resize|wait|whitespace|zero|smaller|larger|((xx?-)?(small|large))|painted|fill|stroke)\b
  192. scope: support.constant.property-value.css
  193. - include: selector
  194. - match: (\b(?i:arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace)\b)
  195. scope: support.constant.font-name.css
  196. - include: string-double
  197. - include: string-single
  198. - match: (rect)\s*(\()
  199. captures:
  200. 1: support.function.misc.css
  201. 2: punctuation.section.function.css
  202. push:
  203. - match: (\))
  204. captures:
  205. 1: punctuation.section.function.css
  206. pop: true
  207. - include: numeric-values
  208. - match: (format|local|url|attr|counter|counters)\s*(\()
  209. captures:
  210. 1: support.function.misc.css
  211. 2: punctuation.section.function.css
  212. push:
  213. - match: (\))
  214. captures:
  215. 1: punctuation.section.function.css
  216. pop: true
  217. - include: string-single
  218. - include: string-double
  219. - match: '[^''") \t]+'
  220. scope: variable.parameter.misc.css
  221. - match: \!\s*important
  222. scope: keyword.other.important.css
  223. rule-list:
  224. - include: comment-block
  225. - include: comment-line
  226. - include: selector
  227. - include: property-names
  228. - match: (:)\s*
  229. captures:
  230. 1: punctuation.separator.key-value.css
  231. push:
  232. - meta_scope: meta.property-value.css
  233. - match: '\s*(;|(?=[{}]))'
  234. captures:
  235. 1: punctuation.terminator.rule.css
  236. pop: true
  237. - include: property-values
  238. selector:
  239. - match: '\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|datalist|dd|del|details|dfn|dialog|div|dl|dt|em|eventsource|fieldset|figure|figcaption|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|label|legend|li|link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|svg|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\b'
  240. scope: entity.name.tag.css, keyword.control.html.elements
  241. - match: '(\.)-?[a-zA-Z_][a-zA-Z0-9_-]*'
  242. scope: entity.other.attribute-name.class.css
  243. captures:
  244. 1: punctuation.definition.entity.css
  245. - match: "(#)-?[a-zA-Z_][a-zA-Z0-9_-]*"
  246. scope: entity.other.attribute-name.id.css
  247. captures:
  248. 1: punctuation.definition.entity.css
  249. - match: \*
  250. scope: entity.name.tag.wildcard.css
  251. - match: (:+)((first|last|only)-child|(first|last|only)-of-type|empty|root|target|first-letter|first-line|first|left|right|lang)\b
  252. scope: entity.other.attribute-name.pseudo-class.css
  253. captures:
  254. 1: punctuation.definition.entity.css
  255. - match: (:)(extend)\b
  256. scope: entity.other.attribute-name.pseudo-class.less
  257. captures:
  258. 1: punctuation.definition.entity.css
  259. - match: (:)(checked|enabled|default|disabled|indeterminate|invalid|optional|required|valid)\b
  260. scope: entity.other.attribute-name.pseudo-class.ui-state.css
  261. captures:
  262. 1: punctuation.definition.entity.css
  263. - match: ((:)not)(\()
  264. captures:
  265. 1: entity.other.attribute-name.pseudo-class.css
  266. 2: punctuation.definition.entity.css
  267. 3: punctuation.section.function.css
  268. push:
  269. - match: \)
  270. captures:
  271. 0: punctuation.section.function.css
  272. pop: true
  273. - include: selector
  274. - match: ((:)nth-(?:(?:last-)?child|(?:last-)?of-type))(\()
  275. captures:
  276. 1: entity.other.attribute-name.pseudo-class.css
  277. 2: punctuation.definition.entity.css
  278. 3: punctuation.section.function.css
  279. push:
  280. - meta_content_scope: constant.numeric.css
  281. - match: (\))
  282. captures:
  283. 1: punctuation.section.function.css
  284. pop: true
  285. - match: (:+)(?:-(?:webkit|moz|o)-)?(after|before|selection|scrollbar|placeholder|input-placeholder)\b
  286. scope: entity.other.attribute-name.pseudo-element.css
  287. captures:
  288. 1: punctuation.definition.entity.css
  289. - match: (:+)(?:-(?:webkit|moz|o)-)?(active|hover|link|visited|focus-inner|focus)\b
  290. scope: entity.other.attribute-name.pseudo-class.css
  291. captures:
  292. 1: punctuation.definition.entity.css
  293. - match: '(?i)(\[)\s*(-?[_a-z\\[[:^ascii:]]][_a-z0-9\-\\[[:^ascii:]]]*)(?:\s*([~|^$*]?=)\s*(?:(-?[_a-z\\[[:^ascii:]]][_a-z0-9\-\\[[:^ascii:]]]*)|((?>([''"])(?:[^\\]|\\.)*?(\6)))))?\s*(\])'
  294. scope: meta.attribute-selector.css
  295. captures:
  296. 1: punctuation.definition.entity.css
  297. 2: entity.other.attribute-name.attribute.css
  298. 3: punctuation.separator.operator.css
  299. 4: string.unquoted.attribute-value.css
  300. 5: string.quoted.double.attribute-value.css
  301. 6: punctuation.definition.string.begin.css
  302. 7: punctuation.definition.string.end.css
  303. string-double:
  304. - match: '"'
  305. captures:
  306. 0: punctuation.definition.string.begin.css
  307. push:
  308. - meta_scope: string.quoted.double.css
  309. - match: '"'
  310. captures:
  311. 0: punctuation.definition.string.end.css
  312. pop: true
  313. - match: \\.
  314. scope: constant.character.escape.css
  315. string-single:
  316. - match: "'"
  317. captures:
  318. 0: punctuation.definition.string.begin.css
  319. push:
  320. - meta_scope: string.quoted.single.css
  321. - match: "'"
  322. captures:
  323. 0: punctuation.definition.string.end.css
  324. pop: true
  325. - match: \\.
  326. scope: constant.character.escape.css