Created
September 7, 2016 00:43
-
-
Save DethAriel/96d63decc0ba4f1c948e898c61086fce to your computer and use it in GitHub Desktop.
Basic TypeScript syntax highlighting rules for FishEye/Crucible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic TypeScript syntax highlighting rules for FishEye/Crucible. | |
# | |
# Put this file to the <FISHEYE_INST>/syntax directory and update the | |
# <FISHEYE_INST>/syntax/filename.map file to contain the following lines: | |
# | |
# "**/*.ts" typescript.def "TypeScript" | |
# | |
# FishEye/Crucible might need to be restarted to have the changes take effect. | |
# | |
# References: | |
# * https://confluence.atlassian.com/display/FISHKB/Defining+your+own+syntax+highlighting+in+Crucible+or+Fisheye | |
# * https://confluence.atlassian.com/display/FISHKB/Configure+syntax+highlighting+for+non-standard+file+extensions | |
# | |
# Notes: | |
# * this schema considers identifiers that start with an uppercase letter to represent classes or constants, so | |
# it treats such identifiers as 'symbol' for better colors. If you don't want such treatment, replace the | |
# 'symbol' with 'identifier'. | |
# | |
# TODO: multiline strings do not really work, e.g.: | |
# var mySuperString = 'this is a \ | |
# multiline string'; | |
syntaxdef typescript { | |
# whitespaces | |
/\s+/m : ; | |
# keywords | |
/\b(a(ny|s)|b(oolean|reak)|c(a(se|tch)|lass|on(st(|ructor)|tinue))|d(e(bugger|clare|fault|lete)|o)|e(lse|num|x(port|tends))|f(alse|inally|or|rom|unction)|get|i(f|mp(lements|ort)|n(|stanceof|terface))|let|module|n(ew|u(ll|mber))|of|p(ackage|r(ivate|otected)|ublic)|r(equire|eturn)|s(et|t(atic|ring)|uper|witch|ymbol)|t(h(is|row)|r(ue|y)|ype(|of))|v(ar|oid)|w(hile|ith)|yield)\b/ : { | |
region { | |
type=keyword; | |
index=word; | |
} | |
} | |
# decorators | |
/@[a-zA-Z_][a-zA-Z0-9_]*/ : { | |
region { | |
type=decorator; | |
index=word; | |
} | |
} | |
# backquote string literal | |
/`/ : { | |
context { | |
/\\`/: ; | |
"`" : exit; | |
/(\$\{.*?\})/ : { | |
region ${1} { | |
type=identifier; | |
index=word; | |
} | |
} | |
} | |
region ${ALL} { | |
type=string; | |
} | |
} | |
# single-quote string literal | |
/'/ : { | |
context { | |
/\\'/: ; | |
/$/m : exit; | |
"'" : exit; | |
} | |
region ${ALL} { | |
type=string; | |
} | |
} | |
# double-quote string literal | |
/"/ : { | |
context { | |
/\\"/: ; | |
/$/m : exit; | |
"\"" : exit; | |
} | |
region ${ALL} { | |
type=string; | |
} | |
} | |
# numbers | |
/(0x[0-9a-f]+)|(([0-9]+\.?)|([0-9]*\.[0-9]+))/i : { | |
region { | |
type=numeric; | |
} | |
} | |
# Identifiers | |
/[a-z_$][a-zA-Z_0-9]*/ : { | |
region { | |
type=identifier; | |
index=word; | |
} | |
} | |
# probable classes or constant expressions | |
/[A-Z][a-zA-Z_0-9]*/ : { | |
region { | |
type=symbol; | |
index=word; | |
} | |
} | |
# multiline comment | |
/\/\*(.*?)\*\//s : { | |
todo(${1}); | |
region { | |
type=comment; | |
findlinks=true; | |
} | |
region ${1} { | |
index=prose; | |
} | |
} | |
# one-line comment | |
/\/\/.*$/m : { | |
todo(${0}); | |
region { | |
type=comment; | |
index=prose; | |
findlinks=true; | |
} | |
} | |
context todo { | |
/(?i)(todo):?\s.*/ : { | |
region { | |
type=todo; | |
} | |
} | |
} | |
# regex | |
/ | |
\/ | |
([^\n\r*\\\/]|\\[^\r\n])# RegularExpressionFirstChar | |
/x : { | |
context { # RegularExpresionChar* | |
/\\[^\r\n]/ : ; | |
/\// : exit; | |
/[\r\n]/ : exit; # for safety | |
} | |
region ${ALL} { | |
type=regex; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@DethAriel Thanks!