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 all 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
290 changes: 265 additions & 25 deletions grammars/less.cson
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
'include': '#strings'
}
{
'captures':
'1':
'name': 'entity.other.attribute-name.class.mixin.css'
'match': '(\\.[_a-zA-Z][a-zA-Z0-9_-]*(?=\\())'
'include': '#mixins'
}
{
'captures':
Expand Down Expand Up @@ -219,11 +216,7 @@
]
}
{
'match': '(@|\\-\\-)[\\w-]+(?=\\s*)'
'name': 'variable.other.less'
'captures':
'1':
'name': 'punctuation.definition.variable.less'
'include': '#variables'
}
{
'include': '#variable_interpolation'
Expand Down Expand Up @@ -270,12 +263,10 @@
"name": "keyword.other.important.css"
}
{
'match': '\\*|\\/|\\-|\\+|~|=|<=|>=|<|>'
'name': 'keyword.operator.less'
'include': '#operators'
}
{
'match': '\\b(not|and|when)\\b'
'name': 'keyword.control.logical.operator.less'
'include': '#logical_operators'
}
{
'include': 'source.css#tag-names'
Expand Down Expand Up @@ -320,22 +311,13 @@
'name': 'punctuation.separator.key-value.css'
}
{
# true is truthy, everything else is false: there is no 'false' keyword
# http://lesscss.org/features/#mixin-guards-feature-guard-comparison-operators
'match': '\\btrue\\b'
'name': 'constant.language.boolean.less'
}
{
'match': '\\bdefault\\b'
'name': 'support.function.default.less'
'include': '#booleans'
}
{
'match': '\\b(isurl|isstring|isnumber|iskeyword|iscolor)\\b'
'name': 'support.function.type-checking.less'
'include': '#function_type_checking'
}
{
'match': '\\b(isunit|ispixel|ispercentage|isem)\\b'
'name': 'support.function.unit-checking.less'
'include': '#function_unit_checking'
}
{
'include': 'source.css#property-keywords'
Expand All @@ -354,6 +336,17 @@
}
]
'repository':
'booleans':
# true is truthy, everything else is false: there is no 'false' keyword
# http://lesscss.org/features/#mixin-guards-feature-guard-comparison-operators
'match': '\\btrue\\b'
'name': 'constant.language.boolean.less'
'variables':
'match': '(@|\\-\\-)[\\w-]+'
'name': 'variable.other.less'
'captures':
'1':
'name': 'punctuation.definition.variable.less'
'variable_interpolation':
'match': '@{[a-zA-Z0-9_-]+}'
'name': 'variable.other.interpolation.less'
Expand Down Expand Up @@ -403,6 +396,12 @@
'brace_round':
'match': '\\(|\\)'
'name': 'meta.brace.round.css'
'operators':
'match': '\\*|\\/|\\-|\\+|~|=|<=|>=|<|>'
'name': 'keyword.operator.less'
'logical_operators':
'match': '\\b(not|and|when)\\b'
'name': 'keyword.control.logical.operator.less'
'property_values':
'begin': '(?<!&)(:)\\s*(?!(\\s*{))(?!.*(?<!@){)'
'beginCaptures':
Expand Down Expand Up @@ -456,3 +455,244 @@
'less_builtin_functions':
'match': '\\b(abs|acos|alpha|argb|asin|atan|average|blue|calc|ceil|color|contrast|convert|convert|cos|darken|data-uri|desaturate|difference|e|escape|exclusion|extract|fade|fadein|fadeout|floor|format|green|greyscale|hardlight|hsl|hsla|hsv|hsva|hsvhue|hsvsaturation|hsvvalue|hue|length|lighten|lightness|luma|max|min|mix|mod|multiply|negation|overlay|percentage|pi|pow|red|replace|round|saturate|saturation|screen|sin|softlight|spin|sqrt|tan|unit)\\b'
'name': 'support.function.any-method.builtin.less'
'function_type_checking':
'begin': '\\b(isurl|isstring|isnumber|iskeyword|iscolor)(\\()'
'beginCaptures':
'1':
'name': 'support.function.type-checking.less'
'2':
'name': 'meta.brace.round.css'
'end': '\\)'
'endCaptures':
'0':
'name': 'meta.brace.round.css'
'patterns': [
{
'include': '#property_values'
}
{
'include': '#variables'
}
]
'function_default':
'match': '\\b(default)(\\()(\\))'
'captures':
'1':
'name': 'support.function.default.less'
'2':
'name': 'meta.brace.round.css'
'3':
'name': 'meta.brace.round.css'
'function_unit_checking':
'begin': '\\b(isunit|ispixel|ispercentage|isem)(\\()'
'beginCaptures':
'1':
'name': 'support.function.unit-checking.less'
'2':
'name': 'meta.brace.round.css'
'end': '\\)'
'endCaptures':
'0':
'name': 'meta.brace.round.css'
'patterns': [
{
'include': '#property_values'
}
{
'include': '#variables'
}
]
'mixins':
'name': 'meta.mixin.less'
'begin': '((\\.)[_a-zA-Z][a-zA-Z0-9_-]*)(?=\\s*\\()'
'beginCaptures':
'0':
'name': 'meta.definition.mixin.less'
'1':
'name': 'entity.name.mixin.less'
'2':
'name': 'punctuation.definition.mixin.less'
'end': '(?<=})'
'patterns': [
{
'include': '#mixin_parameters'
}
{
'include': '#mixin_guards'
}
{
'include': '$self'
}
]
'mixin_parameters':
'name': 'meta.parameters.less'
'begin': '\\((?=\\s*@|\\))'
'beginCaptures':
'0':
'name': 'punctuation.definition.parameters.begin.bracket.round.less'
'end': '\\)'
'endCaptures':
'0':
'name': 'punctuation.definition.parameters.end.bracket.round.less'
'patterns': [
{
'include': '#mixin_parameter_semicolon'
}
{
'include': '#mixin_parameter_comma'
}
{
'include': '#mixin_parameter'
}
]
'mixin_parameter_semicolon':
'begin': '(@)[a-zA-Z][a-zA-Z0-9-]*(?=.*?;)'
'beginCaptures':
'0':
'name': 'variable.parameter.less'
'1':
'name': 'punctuation.definition.variable.less'
'end': ';'
'endCaptures':
'0':
'name': 'punctuation.separator.parameter.less'
'patterns': [
{
'match': ':'
'name': 'punctuation.separator.key-value.less'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@50Wliu Should this be punctuation.separator.key-value.css? Or is it incorrectly set here: https://github.com/atom/language-less/pull/82/files#diff-14c55924b6cf1fe75bf40519b9cddaccR317?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this can be kept as .less.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I change the other occurrence then?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The other one can be kept as .css because that one is the same in CSS, whereas for this one there is no function equivalent in CSS.

It's a bit confusing and is pretty ad-hoc. Hopefully in the future the endings can be standardized.

}
{
'include': 'source.css#numeric-values'
}
{
'include': 'source.css#color-keywords'
}
{
'include': 'source.css#functions'
}
{
'include': '#less_builtin_functions'
}
{
'include': 'source.css#property-keywords'
}
{
'include': '#strings'
}
{
'include': 'source.css#commas'
}
]
'mixin_parameter_comma':
'begin': '(@)[a-zA-Z][a-zA-Z0-9-]*(?=.*?,\\s*@)'
'beginCaptures':
'0':
'name': 'variable.parameter.less'
'1':
'name': 'punctuation.definition.variable.less'
'end': ',(?=\\s*@)'
'endCaptures':
'0':
'name': 'punctuation.separator.parameter.less'
'patterns': [
{
'match': ':'
'name': 'punctuation.separator.key-value.less'
}
{
'include': 'source.css#numeric-values'
}
{
'include': 'source.css#color-keywords'
}
{
'include': 'source.css#functions'
}
{
'include': '#less_builtin_functions'
}
{
'include': 'source.css#property-keywords'
}
{
'include': '#strings'
}
]
'mixin_parameter':
'begin': '(@)[a-zA-Z][a-zA-Z0-9-]*'
'beginCaptures':
'0':
'name': 'variable.parameter.less'
'1':
'name': 'punctuation.definition.variable.less'
'end': '(?=\\))'
'patterns': [
{
'match': ':'
'name': 'punctuation.separator.key-value.less'
}
{
'include': 'source.css#numeric-values'
}
{
'include': 'source.css#color-keywords'
}
{
'include': 'source.css#functions'
}
{
'include': '#less_builtin_functions'
}
{
'include': 'source.css#property-keywords'
}
{
'include': '#strings'
}
{
'include': 'source.css#commas'
}
]
'mixin_guards':
'name': 'meta.guard.less'
'begin': '(?:(when|and|when\\s+not|and\\s+not)\\s*|(,)\\s*)+(\\()'
'beginCaptures':
'1':
'name': 'keyword.control.logical.operator.less'
'2':
'name': 'punctuation.separator.list.comma.css'
'3':
'name': 'meta.brace.round.css'
'end': '\\)'
'endCaptures':
'0':
'name': 'meta.brace.round.css'
'patterns': [
{
'include': '#function_type_checking'
}
{
'include': '#function_default'
}
{
'include': '#function_unit_checking'
}
{
'include': '#property_values'
}
{
'include': '#variables'
}
{
'include': 'source.css#numeric-values'
}
{
'include': '#booleans'
}
{
'include': '#strings'
}
{
'include': '#operators'
}
]
Loading