Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 53 additions & 16 deletions grammars/javascript.cson
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
'2':
'name': 'support.constant.js'
'3':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'comment': 'match stuff like: Sound.prototype = { … } when extending an object'
'match': '([a-zA-Z_?.$][\\w?.$]*)\\.(prototype)\\s*(=)\\s*'
'name': 'meta.class.js'
Expand All @@ -282,7 +282,7 @@
'3':
'name': 'entity.name.function.js'
'4':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'5':
'name': 'storage.modifier.js'
'6':
Expand Down Expand Up @@ -312,7 +312,7 @@
'3':
'name': 'entity.name.function.js'
'4':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'comment': 'match stuff like: Sound.prototype.play = myfunc'
'match': '([a-zA-Z_?.$][\\w?.$]*)\\.(prototype)\\.([a-zA-Z_?.$][\\w?.$]*)\\s*(=)\\s*'
'name': 'meta.function.js'
Expand All @@ -325,7 +325,7 @@
'2':
'name': 'entity.name.function.js'
'3':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'4':
'name': 'storage.modifier.js'
'5':
Expand Down Expand Up @@ -354,7 +354,7 @@
'1':
'name': 'entity.name.function.js'
'2':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'3':
'name': 'storage.modifier.js'
'4':
Expand Down Expand Up @@ -408,7 +408,7 @@
'1':
'name': 'entity.name.function.js'
'2':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'3':
'name': 'storage.modifier.js'
'4':
Expand Down Expand Up @@ -451,7 +451,7 @@
'8':
'name': 'punctuation.definition.string.end.js'
'9':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'10':
'name': 'storage.modifier.js'
'11':
Expand Down Expand Up @@ -538,7 +538,7 @@
'1':
'name': 'entity.name.function.js'
'2':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'3':
'name': 'punctuation.definition.parameters.begin.js'
'end': '(\\))(\\s*=>)'
Expand All @@ -563,7 +563,7 @@
'2':
'name': 'entity.name.function.js'
'3':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'4':
'name': 'punctuation.definition.parameters.begin.js'
'end': '(\\))(\\s*=>)'
Expand Down Expand Up @@ -634,18 +634,20 @@
'beginCaptures':
'1':
'name': 'storage.modifier.js'
'end': '(=|\\bof\\b|\\bin\\b)|(;)|(?<!,)\\n'
'end': '(\\bof\\b|\\bin\\b)|(;)|(=)|(?<!,)\\n'
'endCaptures':
'1':
'name': 'keyword.operator.js'
'name': 'keyword.operator.$1.js'
'2':
'name': 'punctuation.terminator.statement.js'
'3':
'name': 'keyword.operator.assignment.js'
'patterns': [
{
'match': '([$_a-zA-Z][$_a-zA-Z0-9]*)\\s*(:)\\s*([$_a-zA-Z][$_a-zA-Z0-9]*)?'
'captures':
'2':
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
'3':
'name': 'constant.other.js'
}
Expand Down Expand Up @@ -703,7 +705,7 @@
}
{
'match': '(?<!\\.)\\b(delete|in|of|instanceof|new|typeof|void)(?!\\s*:)\\b'
'name': 'keyword.operator.js'
'name': 'keyword.operator.$1.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I have your reasoning behind this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes possible to change highlighting for each of these operators.

}
{
'match': '(?<!\\.)\\b(true|false)(?!\\s*:)\\b|(?<=\\?)(?:\\s*)(true|false)(?=\\s*:)'
Expand Down Expand Up @@ -857,8 +859,43 @@
'operators':
'patterns': [
{
'match': '!=|!==|<=|>=|<<=|>>=|>>>=|\\*=|(?<!\\()/=|%=|\\+=|\\-=|&=|\\^=|!|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\^'
'comment': 'match 2-character operator first'
'match': '%=|\\+=|\\-=|\\*=|(?<!\\()/='
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final nit: The - here doesn't need to be escaped either.

'name': 'keyword.operator.assignment.compound.js'
}
{
'match': '&=|\\^=|<<=|>>=|>>>=|\\|='
'name': 'keyword.operator.assignment.compound.bitwise.js'
}
{
'match': '!==|!=|<=|>=|===|==|<|>'
'name': 'keyword.operator.comparison.js'
}
{
'match': '&&|!|\\|\\|'
'name': 'keyword.operator.logical.js'
}
{
'match': '&|\\||\\^|~'
'name': 'keyword.operator.bitwise.js'
}
{
'match': '\\?|\\:'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: doesn't need to be escaped

'name': 'keyword.operator.js'
}
{
'match': '\\='
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= doesn't need to be escaped

'name': 'keyword.operator.assignment.js'
}
{
'match': '\\-\\-'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-- doesn't need to be escaped

'name': 'keyword.operator.decrement.js'
}
{
'match': '\\+\\+'
'name': 'keyword.operator.increment.js'
}
{
'match': '%|\\*|/|\\-|\\+'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- doesn't need to be escaped

'name': 'keyword.operator.js'
}
]
Expand Down Expand Up @@ -981,7 +1018,7 @@
}
{
'match': '='
'name': 'keyword.operator.js'
'name': 'keyword.operator.assignment.js'
}
{
'include': '#comments'
Expand Down
Loading