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.

201 lines
6.3KB

  1. %YAML 1.2
  2. ---
  3. # http://www.sublimetext.com/docs/3/syntax.html
  4. name: Elm
  5. file_extensions:
  6. - elm
  7. scope: source.elm
  8. contexts:
  9. main:
  10. - match: "(`)[a-zA-Z_']*?(`)"
  11. scope: keyword.operator.function.infix.elm
  12. captures:
  13. 1: punctuation.definition.entity.elm
  14. 2: punctuation.definition.entity.elm
  15. - match: \(\)
  16. scope: constant.language.unit.elm
  17. - match: ^\b((effect|port)\s+)?(module)\s+
  18. captures:
  19. 1: keyword.other.elm
  20. 3: keyword.other.elm
  21. push:
  22. - meta_scope: meta.declaration.module.elm
  23. - match: $|;
  24. captures:
  25. 1: keyword.other.elm
  26. pop: true
  27. - include: module_name
  28. - match: '(where)\s*\{'
  29. captures:
  30. 1: keyword.other.elm
  31. push:
  32. - match: '\}'
  33. pop: true
  34. - include: type_signature
  35. - match: (exposing)
  36. scope: keyword.other.elm
  37. - include: module_exports
  38. - match: (where)
  39. scope: keyword.other.elm
  40. - match: "[a-z]+"
  41. scope: invalid
  42. - match: ^\b(import)\s+((open)\s+)?
  43. captures:
  44. 1: keyword.other.elm
  45. 3: invalid
  46. push:
  47. - meta_scope: meta.import.elm
  48. - match: ($|;)
  49. pop: true
  50. - match: (as|exposing)
  51. scope: keyword.import.elm
  52. - include: module_name
  53. - include: module_exports
  54. - match: '(\[)(glsl)(\|)'
  55. captures:
  56. 1: keyword.other.elm
  57. 2: support.function.prelude.elm
  58. 3: keyword.other.elm
  59. push:
  60. - meta_scope: entity.glsl.elm
  61. - match: '(\|\])'
  62. captures:
  63. 1: keyword.other.elm
  64. pop: true
  65. - include: scope:source.glsl
  66. - match: \b(type alias|type|case|of|let|in|as)\s+
  67. scope: keyword.other.elm
  68. - match: \b(if|then|else)\s+
  69. scope: keyword.control.elm
  70. - match: '\b([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b'
  71. comment: Floats are always decimal
  72. scope: constant.numeric.float.elm
  73. - match: '\b([0-9]+)\b'
  74. scope: constant.numeric.elm
  75. - match: '"""'
  76. captures:
  77. 0: punctuation.definition.string.begin.elm
  78. push:
  79. - meta_scope: string.quoted.double.elm
  80. - match: '"""'
  81. captures:
  82. 0: punctuation.definition.string.end.elm
  83. pop: true
  84. - match: '\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\''\&])'
  85. scope: constant.character.escape.elm
  86. - match: '\^[A-Z@\[\]\\\^_]'
  87. scope: constant.character.escape.control.elm
  88. - match: '"'
  89. captures:
  90. 0: punctuation.definition.string.begin.elm
  91. push:
  92. - meta_scope: string.quoted.double.elm
  93. - match: '"'
  94. captures:
  95. 0: punctuation.definition.string.end.elm
  96. pop: true
  97. - match: '\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\"''\&])'
  98. scope: constant.character.escape.elm
  99. - match: '\^[A-Z@\[\]\\\^_]'
  100. scope: constant.character.escape.control.elm
  101. - match: |-
  102. (?x)
  103. (')
  104. (?:
  105. [\ -\[\]-~] # Basic Char
  106. | (\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE
  107. |DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS
  108. |US|SP|DEL|[abfnrtv\\\"'\&])) # Escapes
  109. | (\^[A-Z@\[\]\\\^_]) # Control Chars
  110. )
  111. (')
  112. scope: string.quoted.single.elm
  113. captures:
  114. 1: punctuation.definition.string.begin.elm
  115. 2: constant.character.escape.elm
  116. 3: punctuation.definition.string.end.elm
  117. - match: '^(port\s+)?([a-z_][a-zA-Z0-9_'']*|\([|!%$+\-.,=</>]+\))\s*((:)([:]+)?)'
  118. captures:
  119. 1: keyword.other.port.elm
  120. 2: entity.name.function.elm
  121. 4: keyword.other.colon.elm
  122. 5: invalid
  123. push:
  124. - meta_scope: meta.function.type-declaration.elm
  125. - match: $\n?
  126. pop: true
  127. - include: type_signature
  128. - match: \bport\s+
  129. scope: keyword.other.port.elm
  130. - match: '\b[A-Z]\w*\b'
  131. scope: constant.other.elm
  132. - include: comments
  133. - match: '^[a-z][A-Za-z0-9_'']*\s+'
  134. scope: entity.name.function.elm
  135. - include: infix_op
  136. - match: '[|!%$?~+:\-.=</>&\\*^]+'
  137. scope: keyword.operator.elm
  138. - match: '([\[\]\{\},])'
  139. scope: constant.language.delimiter.elm
  140. captures:
  141. 1: support.function.delimiter.elm
  142. - match: '([\(\)])'
  143. scope: keyword.other.parenthesis.elm
  144. block_comment:
  145. - match: '\{-(?!#)'
  146. captures:
  147. 0: punctuation.definition.comment.elm
  148. push:
  149. - meta_scope: comment.block.elm
  150. - include: block_comment
  151. - match: '-\}'
  152. captures:
  153. 0: punctuation.definition.comment.elm
  154. pop: true
  155. comments:
  156. - match: (--).*$\n?
  157. scope: comment.line.double-dash.elm
  158. captures:
  159. 1: punctuation.definition.comment.elm
  160. - include: block_comment
  161. infix_op:
  162. - match: '(\([|!%$+:\-.=</>]+\)|\(,+\))'
  163. scope: entity.name.function.infix.elm
  164. module_exports:
  165. - match: \(
  166. push:
  167. - meta_scope: meta.declaration.exports.elm
  168. - match: \)
  169. pop: true
  170. - match: '\b[a-z][a-zA-Z_''0-9]*'
  171. scope: entity.name.function.elm
  172. - match: '\b[A-Z][A-Za-z_''0-9]*'
  173. scope: storage.type.elm
  174. - match: ","
  175. scope: punctuation.separator.comma.elm
  176. - include: infix_op
  177. - match: \(.*?\)
  178. comment: So named because I don't know what to call this.
  179. scope: meta.other.unknown.elm
  180. module_name:
  181. - match: "[A-Z][A-Za-z._']*"
  182. scope: support.other.module.elm
  183. type_signature:
  184. - match: '\(\s*([A-Z][A-Za-z]*)\s+([a-z][A-Za-z_'']*)\)\s*(=>)'
  185. scope: meta.class-constraint.elm
  186. captures:
  187. 1: entity.other.inherited-class.elm
  188. 2: variable.other.generic-type.elm
  189. 3: keyword.other.big-arrow.elm
  190. - match: "->"
  191. scope: keyword.other.arrow.elm
  192. - match: "=>"
  193. scope: keyword.other.big-arrow.elm
  194. - match: '\b[a-z][a-zA-Z0-9_'']*\b'
  195. scope: variable.other.generic-type.elm
  196. - match: '\b[A-Z][a-zA-Z0-9_'']*\b'
  197. scope: storage.type.elm
  198. - match: \(\)
  199. scope: support.constant.unit.elm
  200. - include: comments