Skip to content

Instantly share code, notes, and snippets.

@vol4ok
Created February 11, 2012 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vol4ok/1799026 to your computer and use it in GitHub Desktop.
Save vol4ok/1799026 to your computer and use it in GitHub Desktop.
My TextMate syntax for stylus
{ scopeName = 'source.stylus';
fileTypes = ( 'styl', 'stylus' );
patterns = (
{ name = 'comment.line.stylus';
match = '(?:^[ \t]+)?(\/\/).*$\n?';
captures = { 1 = { name = 'punctuation.definition.comment.stylus'; }; };
},
{ name = 'comment.block.stylus';
begin = '/\*';
end = '\*/';
captures = { 0 = { name = 'punctuation.definition.comment.stylus'; }; };
},
{ name = 'meta.function.stylus';
match = '([-a-zA-Z_][-\w]*)?(\()';
captures = { 1 = { name = 'entity.name.function.stylus'; }; };
},
// { name = 'variable.language.stylus';
// match = '^ *(&|)';
// },
{ name = 'variable.language.stylus';
match = '(arguments)';
},
{ name = 'keyword.stylus';
match = '@([-\w]+)';
},
{ name = 'entity.other.attribute-name.class.stylus';
match = '^ *(\.)[a-zA-Z0-9_-]+';
captures = { 1 = { name = 'punctuation.definition.entity.stylus'; }; };
},
{ name = 'entity.other.attribute-name.pseudo-element.stylus';
match = '(:+)\b(after|before|first-letter|first-line|selection)\b';
captures = { 1 = { name = 'punctuation.definition.entity.stylus'; }; };
},
{ name = 'entity.other.attribute-name.pseudo-class.stylus';
match = '(:{1,2})(?:\b|-)(active|hover|focus|target|link|any-link|local-link|visited|scope|current|past|future|dir|lang|enabled|disabled|checked|indeterminate|default|valid|invalid|in-range|out-of-range|required|optional|read-only|read-write|root|first-child|last-child|only-child|nth-child|nth-last-child|first-of-type|last-of-type|nth-of-type|nth-last-of-type|only-of-type|nth-match|nth-last-match|empty|not|column|nth-column|nth-last-column|moz-placeholder|webkit-input-placeholder|moz-focus-inner|webkit-search-decoration|webkit-search-cancel-button)\b';
captures = { 1 = { name = 'punctuation.definition.entity.stylus'; }; };
},
{ name = 'meta.attribute-selector.css';
match = '(?i)(\[)\s*(-?[_a-z\\[[:^ascii:]]][_a-z0-9\-\\[[:^ascii:]]]*)(?:\s*([~|^$*]?=)\s*(?:(-?[_a-z\\[[:^ascii:]]][_a-z0-9\-\\[[:^ascii:]]]*)|((?>([''"])(?:[^\\]|\\.)*?(\6)))))?\s*(\])';
captures = {
1 = { name = 'punctuation.definition.entity.css'; };
2 = { name = 'entity.other.attribute-name.attribute.css'; };
3 = { name = 'punctuation.separator.operator.css'; };
4 = { name = 'string.unquoted.attribute-value.css'; };
5 = { name = 'string.quoted.double.attribute-value.css'; };
6 = { name = 'punctuation.definition.string.begin.css'; };
7 = { name = 'punctuation.definition.string.end.css'; };
};
},
{ name = 'entity.name.tag.stylus';
match = '\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|datalist|dd|del|details|dfn|dialog|div|dl|dt|em|eventsource|fieldset|figure|figcaption|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|label|legend|li|link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\b';
},
{ name = 'constant.other.color.rgb-value.stylus';
match = '(#)([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b';
captures = { 1 = { name = 'punctuation.definition.constant.stylus'; }; };
},
{ name = 'entity.other.attribute-name.id.stylus';
match = '(#)[a-zA-Z][a-zA-Z0-9_-]*';
captures = { 1 = { name = 'punctuation.definition.entity.stylus'; }; };
},
{ name = 'keyword.control.stylus';
match = '\b(!important|for|in|return|true|false|null|if|else|unless|return)\b';
},
{ name = 'keyword.operator.stylus';
match = '((?:!|~|&|\+|\s-\s|(?:\*)?\*|\/|%|(?:\.)\.\.|<|>|(?:=|:|\?|\+|-|\*|\/|%|<|>)?=|!=)|\b(?:in|is(?:nt)?|not)\b)';
},
{ name = 'string.quoted.double.stylus';
begin = '"';
end = '"';
},
{ name = 'string.quoted.single.stylus';
begin = "'";
end = "'";
},
{ name = 'comment.block.js';
begin = '/\*';
end = '\*/';
captures = { 0 = { name = 'punctuation.definition.comment.js'; }; };
},
{ name = 'support.constant.font-name.stylus';
match = '(\b(?i:arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace)\b)';
},
{ match = '(?x)(?<![a-zA-Z])(
(?:-|\+)?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+))
((?:px|pt|ch|cm|mm|in|r?em|ex|pc|deg|g?rad|dpi|dpcm|s)\b|%)?)';
captures = {
1 = { name = 'constant.numeric.stylus'; };
2 = { name = 'keyword.other.unit.stylus'; };
};
},
{ match = '(-(?:webkit|moz|khtml|o|icab|ms)-(?:background-size|background-clip|border-radius|box-shadow|opacity|border-image|box-sizing|appearance|transition|transform|column-count|column-gap|user-select|text-size-adjust|interpolation-mode))\s*:';
captures = { 1 = { name = 'support.type.property-name.stylus.vendor'; }; };
},
{ match = '\b(azimuth|background-attachment|background-color|background-clip|background-image|background-position|background-repeat|background-size|background|behavior|border-bottom-color|border-bottom-style|border-bottom-width|border-bottom|border-collapse|border-color|border-left-color|border-left-style|border-left-width|border-left|border-right-color|border-right-style|border-right-width|border-right|border-spacing|border-style|border-top-color|border-top-style|border-top-width|border-top|border-width|border-radius|border|box-shadow|bottom|caption-side|clear|clip|color|content|counter-increment|counter-reset|cue-after|cue-before|cue|cursor|direction|display|elevation|empty-cells|float|font-family|font-size-adjust|font-size|font-stretch|font-style|font-variant|font-weight|font|height|left|letter-spacing|line-height|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|marker-offset|margin|marks|max-height|max-width|min-height|min-width|opacity|orphans|outline-color|outline-style|outline-width|outline|overflow(-[xy])?|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page|pause-after|pause-before|pause|pitch-range|pitch|play-during|position|quotes|richness|right|size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|stress|table-layout|text-align|text-decoration|text-indent|text-shadow|text-transform|top|unicode-bidi|vertical-align|visibility|voice-family|volume|white-space|widows|width|word-spacing|z-index|box-sizing|white-space|zoom|outline-offset|transition|transform|column-count|column-gap|user-select|resize|text-size-adjust)(?!-)\s*:?';
captures = { 1 = { name = 'support.type.property-name.stylus'; }; };
},
{ name = 'support.constant.property-value.stylus';
match = '(?:\b|-)(absolute|all(-scroll)?|always|armenian|auto|avoid|baseline|below|bidi-override|block|bold|bolder|border-box|both|bottom|break-all|break-word|capitalize|center|char|circle|cjk-ideographic|col-resize|collapse|content-box|crosshair|dashed|decimal-leading-zero|decimal|default|disabled|disc|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ellipsis|fixed|geometricPrecision|georgian|groove|hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|inactive|inherit|inline-block|inline|inset|inside|inter-ideograph|inter-word|italic|justify|katakana-iroha|katakana|keep-all|left|lighter|line-edge|line-through|line|list-item|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|nw-resize|none|normal|not-allowed|nowrap|oblique|optimize(Legibility|Quality|Speed)|outset|outside|overline|padding-box|pointer|pre(-(wrap|line))?|progress|relative|repeat-x|repeat-y|repeat|right|ridge|row-resize|rtl|s-resize|scroll|se-resize|separate|small-caps|solid|square|static|strict|sub|super|sw-resize|table-footer-group|table-header-group|tb-rl|text-bottom|text-top|text|thick|thin|top|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|vertical(-(ideographic|text))?|visible(Painted|Fill|Stroke)?|w-resize|wait|whitespace|zero|smaller|larger|((xx?-)?(small|large))|painted|fill|stroke|webkit-focus-ring-color|bicubic|textfield)\b';
},
{ name = 'support.constant.color.w3c-standard-color-name.stylus';
comment = 'http://www.w3.org/TR/CSS21/syndata.html#value-def-color';
match = '\b(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow)\b';
},
{ name = 'variable.other.stylus';
match = '[a-zA-Z0-9_-][\w-]*';
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment