| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /**
- * Coffeescript patterns
- *
- * @author Craig Campbell
- */
- Rainbow.extend('coffeescript', [
- {
- name: 'comment.block',
- pattern: /(\#{3})[\s\S]*\1/gm
- },
- {
- name: 'string.block',
- pattern: /('{3}|"{3})[\s\S]*\1/gm
- },
- /**
- * multiline regex with comments
- */
- {
- name: 'string.regex',
- matches: {
- 2: {
- name: 'comment',
- pattern: /\#(.*?)(?=\n)/g
- }
- },
- pattern: /(\/{3})([\s\S]*)\1/gm
- },
- {
- matches: {
- 1: 'keyword'
- },
- pattern: /\b(in|when|is|isnt|of|not|unless|until|super)(?=\b)/gi
- },
- {
- name: 'keyword.operator',
- pattern: /\?/g
- },
- {
- name: 'constant.language',
- pattern: /\b(undefined|yes|on|no|off)\b/g
- },
- {
- name: 'keyword.variable.coffee',
- pattern: /@(\w+)/gi
- },
- /**
- * reset global keywards from generic
- */
- {
- name: 'reset',
- pattern: /object|class|print/gi
- },
- /**
- * named function
- */
- {
- 'matches' : {
- 1: 'entity.name.function',
- 2: 'keyword.operator',
- 3: {
- name: 'function.argument.coffee',
- pattern: /([\@\w]+)/g
- },
- 4: 'keyword.function'
- },
- pattern: /(\w+)\s{0,}(=|:)\s{0,}\((.*?)((-|=)>)/gi
- },
- /**
- * anonymous function
- */
- {
- matches: {
- 1: {
- name: 'function.argument.coffee',
- pattern: /([\@\w]+)/g
- },
- 2: 'keyword.function'
- },
- pattern: /\s\((.*?)\)\s{0,}((-|=)>)/gi
- },
- /**
- * direct function no arguments
- */
- {
- 'matches' : {
- 1: 'entity.name.function',
- 2: 'keyword.operator',
- 3: 'keyword.function'
- },
- pattern: /(\w+)\s{0,}(=|:)\s{0,}((-|=)>)/gi
- },
- /**
- * class definitions
- */
- {
- matches: {
- 1: 'storage.class',
- 2: 'entity.name.class',
- 3: 'storage.modifier.extends',
- 4: 'entity.other.inherited-class'
- },
- pattern: /\b(class)\s(\w+)(\sextends\s)?([\w\\]*)?\b/g
- },
- /**
- * object instantiation
- */
- {
- matches: {
- 1: 'keyword.new',
- 2: {
- name: 'support.class',
- pattern: /\w+/g
- }
- },
- pattern: /\b(new)\s(.*?)(?=\s)/g
- }
- ], 'generic');
- Rainbow.addAlias('coffee', 'coffeescript');
|