Skip to content

Loading…

Massive rewrite #101

Merged
merged 2 commits into from

3 participants

@paulmillr
  • Disable very annoying auto-indentation in textmate 2, just as in Python
  • Fix bug when -> was treated as two operators (- and >).
  • Fix color of function arguments.
  • Add highlighting of:
    • spread operator.
    • built-in classes / constructors.
    • built-in array methods
    • static built-in methods
    • global functions

Before:

After:

@jashkenas jashkenas merged commit ae1c34c into jashkenas:master
@Hubro

This massive rewrite broke something, I can't tell what. All I know is that Sublime Text now gets confused about what functions are. I've attached before and after screenshots to illustrate what I mean:

Before (at 2930525):

before

After (at master HEAD):

after

@jashkenas
Owner

@paulmillr Can you take a crack at fixing this? Otherwise we may have to revert your change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 23, 2012
  1. @paulmillr

    Fix the stuff.

    paulmillr committed
Commits on Mar 26, 2012
  1. @paulmillr

    Revert function syntax.

    paulmillr committed
Showing with 115 additions and 4 deletions.
  1. +17 −0 Preferences/Disable Indent Corrections.tmPreferences
  2. +98 −4 Syntaxes/CoffeeScript.tmLanguage
View
17 Preferences/Disable Indent Corrections.tmPreferences
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>name</key>
+ <string>Disable Indent Corrections</string>
+ <key>scope</key>
+ <string>source.coffee</string>
+ <key>settings</key>
+ <dict>
+ <key>disableIndentCorrections</key>
+ <true/>
+ </dict>
+ <key>uuid</key>
+ <string>5E57C0C3-77D5-4809-A131-F777EE264908</string>
+</dict>
+</plist>
View
102 Syntaxes/CoffeeScript.tmLanguage
@@ -222,13 +222,22 @@
</dict>
<dict>
<key>match</key>
- <string>\b(?&lt;![\.\$])(break|by|catch|continue|else|finally|for|in|of|if|return|switch|then|throw|try|unless|when|while|until|loop|do|(?&lt;=for)\s+own)(?!\s*:)\b</string>
+ <string>(?x)
+ \b(?&lt;![\.\$])(
+ break|by|catch|continue|else|finally|for|in|of|if|return|switch|
+ then|throw|try|unless|when|while|until|loop|do|(?&lt;=for)\s+own
+ )(?!\s*:)\b
+ </string>
<key>name</key>
<string>keyword.control.coffee</string>
</dict>
<dict>
<key>match</key>
- <string>and=|or=|!|%|&amp;|\^|\*|\/|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|&lt;=|&gt;=|&lt;&lt;=|&gt;&gt;=|&gt;&gt;&gt;=|&lt;&gt;|&lt;|&gt;|!|&amp;&amp;|\?|\||\|\||\:|\*=|(?&lt;!\()/=|%=|\+=|\-=|&amp;=|\^=|\b(?&lt;![\.\$])(instanceof|new|delete|typeof|and|or|is|isnt|not)\b</string>
+ <string>(?x)
+ and=|or=|!|%|&amp;|\^|\*|\/|(\-)?\-(?!&gt;)|\+\+|\+|~|==|=(?!&gt;)|!=|&lt;=|&gt;=|&lt;&lt;=|&gt;&gt;=|
+ &gt;&gt;&gt;=|&lt;&gt;|&lt;|&gt;|!|&amp;&amp;|\.\.(\.)?|\?|\||\|\||\:|\*=|(?&lt;!\()/=|%=|\+=|\-=|&amp;=|
+ \^=|\b(?&lt;![\.\$])(instanceof|new|delete|typeof|and|or|is|isnt|not)\b
+ </string>
<key>name</key>
<string>keyword.operator.coffee</string>
</dict>
@@ -328,13 +337,20 @@
</dict>
</dict>
<key>match</key>
- <string>(\s*)(?=[a-zA-Z\$_])([a-zA-Z\$_](\w|\$|:|\.)*\s*(?=[:=](\s*\(.*\))?\s*((=|-)&gt;)))</string>
+ <string>(?x)
+ (\s*)
+ (?=[a-zA-Z\$_])
+ (
+ [a-zA-Z\$_](\w|\$|:|\.)*\s*
+ (?=[:=](\s*\(.*\))?\s*([=-]&gt;))
+ )
+ </string>
<key>name</key>
<string>meta.function.coffee</string>
</dict>
<dict>
<key>match</key>
- <string>(=|-)&gt;</string>
+ <string>[=-]&gt;</string>
<key>name</key>
<string>storage.type.function.coffee</string>
</dict>
@@ -399,6 +415,84 @@
</dict>
<dict>
<key>match</key>
+ <string>(?x)\b(
+ Array|ArrayBuffer|Blob|Boolean|Date|document|event|Function|
+ Int(8|16|32|64)Array|Math|Map|Number|
+ Object|Proxy|RegExp|Set|String|WeakMap|
+ window|Uint(8|16|32|64)Array|XMLHttpRequest
+ )\b</string>
+ <key>name</key>
+ <string>support.class.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>\b(console)\b</string>
+ <key>name</key>
+ <string>entity.name.type.object.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>((?&lt;=console\.)(debug|warn|info|log|error|time|timeEnd|assert))\b</string>
+ <key>name</key>
+ <string>support.function.console.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(?x)\b(
+ decodeURI(Component)?|encodeURI(Component)?|eval|parse(Float|Int)|require
+ )\b</string>
+ <key>name</key>
+ <string>support.function.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(?x)((?&lt;=\.)(
+ apply|call|concat|every|filter|forEach|from|hasOwnProperty|indexOf|
+ isPrototypeOf|join|lastIndexOf|map|of|pop|propertyIsEnumerable|push|
+ reduce(Right)?|reverse|shift|slice|some|sort|splice|to(Locale)?String|
+ unshift|valueOf
+ ))\b</string>
+ <key>name</key>
+ <string>support.function.method.array.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(?x)((?&lt;=Array\.)(
+ isArray
+ ))\b</string>
+ <key>name</key>
+ <string>support.function.static.array.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(?x)((?&lt;=Object\.)(
+ create|definePropert(ies|y)|freeze|getOwnProperty(Descriptors?|Names)|
+ getProperty(Descriptor|Names)|getPrototypeOf|is(Extensible|Frozen|Sealed)?|
+ isnt|keys|preventExtensions|seal
+ ))\b</string>
+ <key>name</key>
+ <string>support.function.static.object.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(?x)((?&lt;=Math\.)(
+ abs|acos|acosh|asin|asinh|atan|atan2|atanh|ceil|cos|cosh|exp|expm1|floor|
+ hypot|log|log10|log1p|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|
+ tan|tanh|trunc
+ ))\b</string>
+ <key>name</key>
+ <string>support.function.static.math.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
+ <string>(?x)((?&lt;=Number\.)(
+ is(Finite|Integer|NaN)|toInteger
+ ))\b</string>
+ <key>name</key>
+ <string>support.function.static.number.coffee</string>
+ </dict>
+ <dict>
+ <key>match</key>
<string>\b(Infinity|NaN|undefined)\b</string>
<key>name</key>
<string>constant.language.coffee</string>
Something went wrong with that request. Please try again.