├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── grammars ├── typescript-grammars-only-tsx.cson └── typescript-grammars-only.cson ├── package.json ├── settings ├── language-typescript-grammars-only-tsx.cson └── language-typescript-grammars-only.cson └── snippets └── language-typescript-grammars-only.cson /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 1.6.0 / 2017-01-24 3 | ================== 4 | 5 | * Merge pull request #15 from aLANparty/sync-atom-typescript-v10.1.13 6 | * Fix atom 1.13 issues 7 | * Sync grammar files with the updates from TypeStrong/atom-typescript v10.1.13 8 | 9 | 1.4.0 / 2016-06-08 10 | ================== 11 | 12 | * Update grammar to latest available from atom-typescript. 13 | 14 | 1.3.1 / 2016-03-07 15 | ================== 16 | 17 | * Fix public keyword typo 18 | 19 | 1.3.0 / 2015-09-28 20 | ================== 21 | 22 | * Added support for tsx files 23 | 24 | 1.2.0 / 2015-09-08 25 | ================== 26 | 27 | * keep up to date with [atom-typescript](https://github.com/TypeStrong/atom-typescript/) 28 | 29 | 1.1.0 / 2015-07-06 30 | ================== 31 | 32 | * adding console snippets 33 | 34 | 1.0.0 / 2015-06-25 35 | ================== 36 | 37 | * adding disclamer for package name 38 | * cloning grammars and snippets from [atom-typescript](https://github.com/TypeStrong/atom-typescript) 39 | * adding settings 40 | * init 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TypeScript language support in Atom 2 | 3 | All respect to [Atom TypeScript](https://github.com/TypeStrong/atom-typescript), but for me it did too much, so I decided to make grammar only language package version. 4 | 5 | I can't call this package `language-typescript` because that package is deprecated somehow. 6 | -------------------------------------------------------------------------------- /grammars/typescript-grammars-only.cson: -------------------------------------------------------------------------------- 1 | 2 | # This file is generated by "scripts/grammar.ts" 3 | # Last generated: Sun, 11 Dec 2016 23:44:50 GMT 4 | 5 | name: "TypeScript" 6 | scopeName: "source.ts" 7 | fileTypes: [ 8 | "ts" 9 | ] 10 | uuid: "ef98eb90-bf9b-11e4-bb52-0800200c9a66" 11 | patterns: [ 12 | { 13 | include: "#directives" 14 | } 15 | { 16 | include: "#statements" 17 | } 18 | { 19 | name: "comment.line.shebang.ts" 20 | match: "\\A(#!).*(?=$)" 21 | captures: 22 | "1": 23 | name: "punctuation.definition.comment.ts" 24 | } 25 | ] 26 | repository: 27 | statements: 28 | patterns: [ 29 | { 30 | comment: "Match full triple slash reference comments" 31 | match: "(\\/\\/\\/\\s*)" 32 | captures: 33 | "1": 34 | name: "keyword.other.ts" 35 | "2": 36 | name: "reference.path.string.quoted" 37 | "3": 38 | name: "keyword.other.ts" 39 | } 40 | { 41 | comment: "Match )" 43 | captures: 44 | "1": 45 | name: "keyword.other.ts" 46 | "2": 47 | name: "amd.path.string.quoted" 48 | "3": 49 | name: "keyword.other.ts" 50 | } 51 | { 52 | comment: "Match )" 54 | captures: 55 | "1": 56 | name: "keyword.other.ts" 57 | "2": 58 | name: "amd.path.string.quoted" 59 | "3": 60 | name: "keyword.other.ts" 61 | } 62 | { 63 | include: "#string" 64 | } 65 | { 66 | include: "#template" 67 | } 68 | { 69 | include: "#comment" 70 | } 71 | { 72 | include: "#literal" 73 | } 74 | { 75 | include: "#declaration" 76 | } 77 | { 78 | include: "#switch-statement" 79 | } 80 | { 81 | include: "#for-loop" 82 | } 83 | { 84 | include: "#after-operator-block" 85 | } 86 | { 87 | include: "#decl-block" 88 | } 89 | { 90 | include: "#control-statement" 91 | } 92 | { 93 | include: "#expression" 94 | } 95 | { 96 | include: "#punctuation-semicolon" 97 | } 98 | ] 99 | "var-expr": 100 | name: "meta.var.expr.ts" 101 | begin: "(?) | 136 | ((<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)) 137 | ) | 138 | (:\\s*( 139 | (<) | 140 | ([(]\\s*( 141 | ([)]) | 142 | (\\.\\.\\.) | 143 | ([_$[:alnum:]]+\\s*( 144 | ([:,?=])| 145 | ([)]\\s*=>) 146 | )) 147 | ))) 148 | ) 149 | ) 150 | ''' 151 | beginCaptures: 152 | "1": 153 | name: "meta.definition.variable.ts syntax--entity.entity.name.function.ts" 154 | end: "(?=$|[;,=}]|(\\s+(of|in)\\s+))" 155 | patterns: [ 156 | { 157 | include: "#type-annotation" 158 | } 159 | { 160 | include: "#string" 161 | } 162 | { 163 | include: "#comment" 164 | } 165 | ] 166 | } 167 | { 168 | name: "meta.var-single-variable.expr.ts" 169 | begin: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" 170 | beginCaptures: 171 | "1": 172 | name: "meta.definition.variable.ts syntax--variable.variable.other.constant.ts" 173 | end: "(?=$|[;,=}]|(\\s+(of|in)\\s+))" 174 | } 175 | { 176 | name: "meta.var-single-variable.expr.ts" 177 | begin: "([_$[:alpha:]][_$[:alnum:]]*)" 178 | beginCaptures: 179 | "1": 180 | name: "meta.definition.variable.ts syntax--variable.variable.other.readwrite.ts" 181 | end: "(?=$|[;,=}]|(\\s+(of|in)\\s+))" 182 | patterns: [ 183 | { 184 | include: "#type-annotation" 185 | } 186 | { 187 | include: "#string" 188 | } 189 | { 190 | include: "#comment" 191 | } 192 | ] 193 | } 194 | ] 195 | "destructuring-variable": 196 | patterns: [ 197 | { 198 | name: "meta.object-binding-pattern-variable.ts" 199 | begin: "(?) | 1052 | ((<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)) 1053 | ) | 1054 | (:\\s*( 1055 | (<) | 1056 | ([(]\\s*( 1057 | ([)]) | 1058 | (\\.\\.\\.) | 1059 | ([_$[:alnum:]]+\\s*( 1060 | ([:,?=])| 1061 | ([)]\\s*=>) 1062 | )) 1063 | ))) 1064 | ) 1065 | ) 1066 | ''' 1067 | } 1068 | { 1069 | name: "meta.definition.property.ts syntax--variable.variable.object.property.ts" 1070 | match: "[_$[:alpha:]][_$[:alnum:]]*" 1071 | } 1072 | { 1073 | name: "keyword.operator.optional.ts" 1074 | match: "\\?" 1075 | } 1076 | ] 1077 | } 1078 | ] 1079 | "method-declaration": 1080 | name: "meta.method.declaration.ts" 1081 | begin: "(?) | 1366 | ((<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)) 1367 | ) | 1368 | (:\\s*( 1369 | (<) | 1370 | ([(]\\s*( 1371 | ([)]) | 1372 | (\\.\\.\\.) | 1373 | ([_$[:alnum:]]+\\s*( 1374 | ([:,?=])| 1375 | ([)]\\s*=>) 1376 | )) 1377 | ))) 1378 | ) 1379 | ) 1380 | ''' 1381 | captures: 1382 | "1": 1383 | name: "storage.modifier.ts" 1384 | "2": 1385 | name: "keyword.operator.rest.ts" 1386 | "3": 1387 | name: "entity.name.function.ts" 1388 | "4": 1389 | name: "keyword.operator.optional.ts" 1390 | } 1391 | { 1392 | match: "(?:\\s*\\b(public|private|protected|readonly)\\s+)?(\\.\\.\\.)?\\s*(?])|(?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)" 1576 | patterns: [ 1577 | { 1578 | include: "#comment" 1579 | } 1580 | { 1581 | include: "#type" 1582 | } 1583 | ] 1584 | type: 1585 | name: "meta.type.ts" 1586 | patterns: [ 1587 | { 1588 | include: "#comment" 1589 | } 1590 | { 1591 | include: "#string" 1592 | } 1593 | { 1594 | include: "#numeric-literal" 1595 | } 1596 | { 1597 | include: "#type-primitive" 1598 | } 1599 | { 1600 | include: "#type-builtin-literals" 1601 | } 1602 | { 1603 | include: "#type-parameters" 1604 | } 1605 | { 1606 | include: "#type-tuple" 1607 | } 1608 | { 1609 | include: "#type-object" 1610 | } 1611 | { 1612 | include: "#type-operators" 1613 | } 1614 | { 1615 | include: "#type-fn-type-parameters" 1616 | } 1617 | { 1618 | include: "#type-paren-or-function-parameters" 1619 | } 1620 | { 1621 | include: "#type-function-return-type" 1622 | } 1623 | { 1624 | include: "#type-name" 1625 | } 1626 | ] 1627 | "function-parameters": 1628 | name: "meta.parameters.ts" 1629 | begin: "\\(" 1630 | beginCaptures: 1631 | "0": 1632 | name: "punctuation.definition.parameters.begin.ts" 1633 | end: "\\)" 1634 | endCaptures: 1635 | "0": 1636 | name: "punctuation.definition.parameters.end.ts" 1637 | patterns: [ 1638 | { 1639 | include: "#comment" 1640 | } 1641 | { 1642 | include: "#decorator" 1643 | } 1644 | { 1645 | include: "#destructuring-parameter" 1646 | } 1647 | { 1648 | include: "#parameter-name" 1649 | } 1650 | { 1651 | include: "#type-annotation" 1652 | } 1653 | { 1654 | include: "#variable-initializer" 1655 | } 1656 | { 1657 | name: "punctuation.separator.parameter.ts" 1658 | match: "," 1659 | } 1660 | ] 1661 | "type-primitive": 1662 | name: "support.type.primitive.ts" 1663 | match: "(?)\\s*(?=\\()" 1710 | end: "(?<=\\))" 1711 | patterns: [ 1712 | { 1713 | include: "#function-parameters" 1714 | } 1715 | ] 1716 | } 1717 | { 1718 | name: "meta.type.function.ts" 1719 | begin: ''' 1720 | (?x)( 1721 | (?= 1722 | [(]\\s*( 1723 | ([)]) | 1724 | (\\.\\.\\.) | 1725 | ([_$[:alnum:]]+\\s*( 1726 | ([:,?=])| 1727 | ([)]\\s*=>) 1728 | )) 1729 | ) 1730 | ) 1731 | ) 1732 | ''' 1733 | end: "(?<=\\))" 1734 | patterns: [ 1735 | { 1736 | include: "#function-parameters" 1737 | } 1738 | ] 1739 | } 1740 | ] 1741 | "type-operators": 1742 | patterns: [ 1743 | { 1744 | include: "#typeof-operator" 1745 | } 1746 | { 1747 | name: "keyword.operator.type.ts" 1748 | match: "[&|]" 1749 | } 1750 | { 1751 | name: "keyword.operator.expression.keyof.ts" 1752 | match: "(?" 1758 | beginCaptures: 1759 | "0": 1760 | name: "storage.type.function.arrow.ts" 1761 | end: "(?)(?=[,\\]\\)\\{\\}=;>]|//|$)" 1762 | patterns: [ 1763 | { 1764 | include: "#comment" 1765 | } 1766 | { 1767 | name: "meta.object.type.ts" 1768 | begin: "(?<==>)\\s*(\\{)" 1769 | beginCaptures: 1770 | "1": 1771 | name: "punctuation.definition.block.ts" 1772 | end: "\\}" 1773 | endCaptures: 1774 | "0": 1775 | name: "punctuation.definition.block.ts" 1776 | patterns: [ 1777 | { 1778 | include: "#type-object-members" 1779 | } 1780 | ] 1781 | } 1782 | { 1783 | include: "#type-predicate-operator" 1784 | } 1785 | { 1786 | include: "#type" 1787 | } 1788 | ] 1789 | "type-tuple": 1790 | name: "meta.type.tuple.ts" 1791 | begin: "\\[" 1792 | beginCaptures: 1793 | "0": 1794 | name: "meta.brace.square.ts" 1795 | end: "\\]" 1796 | endCaptures: 1797 | "0": 1798 | name: "meta.brace.square.ts" 1799 | patterns: [ 1800 | { 1801 | include: "#type" 1802 | } 1803 | { 1804 | include: "#punctuation-comma" 1805 | } 1806 | ] 1807 | "type-name": 1808 | patterns: [ 1809 | { 1810 | match: "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)" 1811 | captures: 1812 | "1": 1813 | name: "entity.name.type.module.ts" 1814 | "2": 1815 | name: "punctuation.accessor.ts" 1816 | } 1817 | { 1818 | name: "entity.name.type.ts" 1819 | match: "[_$[:alpha:]][_$[:alnum:]]*" 1820 | } 1821 | ] 1822 | "type-parameters": 1823 | name: "meta.type.parameters.ts" 1824 | begin: "(<)" 1825 | beginCaptures: 1826 | "1": 1827 | name: "punctuation.definition.typeparameters.begin.ts" 1828 | end: "(?=$)|(>)" 1829 | endCaptures: 1830 | "1": 1831 | name: "punctuation.definition.typeparameters.end.ts" 1832 | patterns: [ 1833 | { 1834 | include: "#comment" 1835 | } 1836 | { 1837 | name: "storage.modifier.ts" 1838 | match: "(?]|\\<[^<>]+\\>)+>\\s*)?\\() 2133 | ''' 2134 | captures: 2135 | "1": 2136 | name: "punctuation.accessor.ts" 2137 | "2": 2138 | name: "support.constant.dom.ts" 2139 | "3": 2140 | name: "support.variable.property.dom.ts" 2141 | } 2142 | { 2143 | name: "support.class.node.ts" 2144 | match: ''' 2145 | (?x)(?]|\\<[^<>]+\\>)+>\\s*)?\\()" 2281 | end: "(?<=\\))(?!(\\.\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\()" 2282 | patterns: [ 2283 | { 2284 | include: "#support-objects" 2285 | } 2286 | { 2287 | include: "#punctuation-accessor" 2288 | } 2289 | { 2290 | name: "entity.name.function.ts" 2291 | match: "([_$[:alpha:]][_$[:alnum:]]*)" 2292 | } 2293 | { 2294 | include: "#comment" 2295 | } 2296 | { 2297 | name: "meta.type.parameters.ts" 2298 | begin: "\\<" 2299 | beginCaptures: 2300 | "0": 2301 | name: "punctuation.definition.typeparameters.begin.ts" 2302 | end: "\\>" 2303 | endCaptures: 2304 | "0": 2305 | name: "punctuation.definition.typeparameters.end.ts" 2306 | patterns: [ 2307 | { 2308 | include: "#type" 2309 | } 2310 | { 2311 | include: "#punctuation-comma" 2312 | } 2313 | ] 2314 | } 2315 | { 2316 | include: "#paren-expression" 2317 | } 2318 | ] 2319 | identifiers: 2320 | patterns: [ 2321 | { 2322 | name: "support.class.ts" 2323 | match: "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\.\\s*prototype\\b(?!\\$))" 2324 | } 2325 | { 2326 | match: ''' 2327 | (?x)(\\.)\\s*(?: 2328 | ([[:upper:]][_$[:digit:][:upper:]]*) | 2329 | ([_$[:alpha:]][_$[:alnum:]]*) 2330 | )(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*) 2331 | ''' 2332 | captures: 2333 | "1": 2334 | name: "punctuation.accessor.ts" 2335 | "2": 2336 | name: "variable.other.constant.object.property.ts" 2337 | "3": 2338 | name: "variable.other.object.property.ts" 2339 | } 2340 | { 2341 | match: ''' 2342 | (?x)(?:(\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*( 2343 | (async\\s+)|(function\\s*[(<])|(function\\s+)| 2344 | ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)| 2345 | ((<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>))) 2346 | ''' 2347 | captures: 2348 | "1": 2349 | name: "punctuation.accessor.ts" 2350 | "2": 2351 | name: "entity.name.function.ts" 2352 | } 2353 | { 2354 | match: "(\\.)\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" 2355 | captures: 2356 | "1": 2357 | name: "punctuation.accessor.ts" 2358 | "2": 2359 | name: "variable.other.constant.property.ts" 2360 | } 2361 | { 2362 | match: "(\\.)\\s*([_$[:alpha:]][_$[:alnum:]]*)" 2363 | captures: 2364 | "1": 2365 | name: "punctuation.accessor.ts" 2366 | "2": 2367 | name: "variable.other.property.ts" 2368 | } 2369 | { 2370 | match: ''' 2371 | (?x)(?: 2372 | ([[:upper:]][_$[:digit:][:upper:]]*) | 2373 | ([_$[:alpha:]][_$[:alnum:]]*) 2374 | )(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*) 2375 | ''' 2376 | captures: 2377 | "1": 2378 | name: "variable.other.constant.object.ts" 2379 | "2": 2380 | name: "variable.other.object.ts" 2381 | } 2382 | { 2383 | name: "variable.other.constant.ts" 2384 | match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" 2385 | } 2386 | { 2387 | name: "variable.other.readwrite.ts" 2388 | match: "[_$[:alpha:]][_$[:alnum:]]*" 2389 | } 2390 | ] 2391 | cast: 2392 | name: "cast.expr.ts" 2393 | begin: "(?:(?<=return|throw|yield|await|default|^|[=(,:>*]))\\s*(<)(?!" 2398 | endCaptures: 2399 | "0": 2400 | name: "meta.brace.angle.ts" 2401 | patterns: [ 2402 | { 2403 | include: "#type" 2404 | } 2405 | ] 2406 | "new-expr": 2407 | name: "new.expr.ts" 2408 | begin: "(?)| 2464 | ((<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)))) 2465 | ''' 2466 | beginCaptures: 2467 | "0": 2468 | name: "meta.object-literal.key.ts" 2469 | "1": 2470 | name: "entity.name.function.ts" 2471 | "2": 2472 | name: "punctuation.separator.key-value.ts" 2473 | end: "(?=,|\\})" 2474 | patterns: [ 2475 | { 2476 | include: "#expression" 2477 | } 2478 | ] 2479 | } 2480 | { 2481 | name: "meta.object.member.ts" 2482 | begin: "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(:)" 2483 | beginCaptures: 2484 | "0": 2485 | name: "meta.object-literal.key.ts" 2486 | "1": 2487 | name: "punctuation.separator.key-value.ts" 2488 | end: "(?=,|\\})" 2489 | patterns: [ 2490 | { 2491 | include: "#expression" 2492 | } 2493 | ] 2494 | } 2495 | { 2496 | name: "meta.object.member.ts" 2497 | begin: "\\.\\.\\." 2498 | beginCaptures: 2499 | "0": 2500 | name: "keyword.operator.spread.ts" 2501 | end: "(?=,|\\})" 2502 | patterns: [ 2503 | { 2504 | include: "#expression" 2505 | } 2506 | ] 2507 | } 2508 | { 2509 | name: "meta.object.member.ts" 2510 | match: "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)" 2511 | captures: 2512 | "1": 2513 | name: "variable.other.readwrite.ts" 2514 | } 2515 | { 2516 | include: "#punctuation-comma" 2517 | } 2518 | ] 2519 | "expression-operators": 2520 | patterns: [ 2521 | { 2522 | name: "keyword.control.flow.ts" 2523 | match: "(?>=|>>>=|\\|=" 2575 | } 2576 | { 2577 | name: "keyword.operator.bitwise.shift.ts" 2578 | match: "<<|>>>|>>" 2579 | } 2580 | { 2581 | name: "keyword.operator.comparison.ts" 2582 | match: "===|!==|==|!=" 2583 | } 2584 | { 2585 | name: "keyword.operator.relational.ts" 2586 | match: "<=|>=|<>|<|>" 2587 | } 2588 | { 2589 | name: "keyword.operator.logical.ts" 2590 | match: "\\!|&&|\\|\\|" 2591 | } 2592 | { 2593 | name: "keyword.operator.bitwise.ts" 2594 | match: "\\&|~|\\^|\\|" 2595 | } 2596 | { 2597 | name: "keyword.operator.assignment.ts" 2598 | match: "\\=" 2599 | } 2600 | { 2601 | name: "keyword.operator.decrement.ts" 2602 | match: "--" 2603 | } 2604 | { 2605 | name: "keyword.operator.increment.ts" 2606 | match: "\\+\\+" 2607 | } 2608 | { 2609 | name: "keyword.operator.arithmetic.ts" 2610 | match: "%|\\*|/|-|\\+" 2611 | } 2612 | { 2613 | match: "(?<=[_$[:alnum:])])\\s*(/)(?![/*])" 2614 | captures: 2615 | "1": 2616 | name: "keyword.operator.arithmetic.ts" 2617 | } 2618 | ] 2619 | "typeof-operator": 2620 | name: "keyword.operator.expression.typeof.ts" 2621 | match: "(?)" 2634 | captures: 2635 | "1": 2636 | name: "storage.modifier.async.ts" 2637 | "2": 2638 | name: "variable.parameter.ts" 2639 | } 2640 | { 2641 | name: "meta.arrow.ts" 2642 | begin: "(?x)\\s*(?=(<([^<>]|\\<[^<>]+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)" 2643 | end: "(?==>)" 2644 | patterns: [ 2645 | { 2646 | include: "#comment" 2647 | } 2648 | { 2649 | include: "#type-parameters" 2650 | } 2651 | { 2652 | include: "#function-parameters" 2653 | } 2654 | { 2655 | include: "#arrow-return-type" 2656 | } 2657 | ] 2658 | } 2659 | { 2660 | name: "meta.arrow.ts" 2661 | begin: "=>" 2662 | beginCaptures: 2663 | "0": 2664 | name: "storage.type.function.arrow.ts" 2665 | end: "(?<=\\})|((?!\\{)(?=\\S))" 2666 | patterns: [ 2667 | { 2668 | include: "#decl-block" 2669 | } 2670 | { 2671 | include: "#expression" 2672 | } 2673 | ] 2674 | } 2675 | ] 2676 | "arrow-return-type": 2677 | name: "meta.return.type.arrow.ts" 2678 | begin: "(?<=\\))\\s*(:)" 2679 | beginCaptures: 2680 | "1": 2681 | name: "keyword.operator.type.annotation.ts" 2682 | end: "(?|;|//))" 2683 | patterns: [ 2684 | { 2685 | include: "#type-predicate-operator" 2686 | } 2687 | { 2688 | include: "#type" 2689 | } 2690 | ] 2691 | "punctuation-comma": 2692 | name: "punctuation.separator.comma.ts" 2693 | match: "," 2694 | "punctuation-semicolon": 2695 | name: "punctuation.terminator.statement.ts" 2696 | match: ";" 2697 | "punctuation-accessor": 2698 | name: "punctuation.accessor.ts" 2699 | match: "\\." 2700 | "paren-expression": 2701 | begin: "\\(" 2702 | beginCaptures: 2703 | "0": 2704 | name: "meta.brace.round.ts" 2705 | end: "\\)" 2706 | endCaptures: 2707 | "0": 2708 | name: "meta.brace.round.ts" 2709 | patterns: [ 2710 | { 2711 | include: "#expression" 2712 | } 2713 | { 2714 | include: "#punctuation-comma" 2715 | } 2716 | ] 2717 | "qstring-double": 2718 | name: "string.quoted.double.ts" 2719 | begin: "\"" 2720 | beginCaptures: 2721 | "0": 2722 | name: "punctuation.definition.string.begin.ts" 2723 | end: "(\")|((?:[^\\\\\\n])$)" 2724 | endCaptures: 2725 | "1": 2726 | name: "punctuation.definition.string.end.ts" 2727 | "2": 2728 | name: "invalid.illegal.newline.ts" 2729 | patterns: [ 2730 | { 2731 | include: "#string-character-escape" 2732 | } 2733 | ] 2734 | "qstring-single": 2735 | name: "string.quoted.single.ts" 2736 | begin: "'" 2737 | beginCaptures: 2738 | "0": 2739 | name: "punctuation.definition.string.begin.ts" 2740 | end: "(\\')|((?:[^\\\\\\n])$)" 2741 | endCaptures: 2742 | "1": 2743 | name: "punctuation.definition.string.end.ts" 2744 | "2": 2745 | name: "invalid.illegal.newline.ts" 2746 | patterns: [ 2747 | { 2748 | include: "#string-character-escape" 2749 | } 2750 | ] 2751 | regex: 2752 | patterns: [ 2753 | { 2754 | name: "string.regex.ts" 2755 | begin: "(?<=[=(:,\\[?+!]|return|case|=>|&&|\\|\\||\\*\\/)\\s*(/)(?![/*])(?=(?:[^/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+/(?![/*])[gimy]*(?!\\s*[a-zA-Z0-9_$]))" 2756 | beginCaptures: 2757 | "1": 2758 | name: "punctuation.definition.string.begin.ts" 2759 | end: "(/)([gimuy]*)" 2760 | endCaptures: 2761 | "1": 2762 | name: "punctuation.definition.string.end.ts" 2763 | "2": 2764 | name: "keyword.other.ts" 2765 | patterns: [ 2766 | { 2767 | include: "#regexp" 2768 | } 2769 | ] 2770 | } 2771 | { 2772 | name: "string.regex.ts" 2773 | begin: "(?\\s*$)" 3134 | beginCaptures: 3135 | "1": 3136 | name: "punctuation.definition.comment.ts" 3137 | end: "(?=$)" 3138 | patterns: [ 3139 | { 3140 | name: "meta.tag.ts" 3141 | begin: "(<)(reference|amd-dependency|amd-module)" 3142 | beginCaptures: 3143 | "1": 3144 | name: "punctuation.definition.tag.directive.ts" 3145 | "2": 3146 | name: "entity.name.tag.directive.ts" 3147 | end: "/>" 3148 | endCaptures: 3149 | "0": 3150 | name: "punctuation.definition.tag.directive.ts" 3151 | patterns: [ 3152 | { 3153 | name: "entity.other.attribute-name.directive.ts" 3154 | match: "path|types|no-default-lib|name" 3155 | } 3156 | { 3157 | name: "keyword.operator.assignment.ts" 3158 | match: "=" 3159 | } 3160 | { 3161 | include: "#string" 3162 | } 3163 | ] 3164 | } 3165 | ] 3166 | docblock: 3167 | patterns: [ 3168 | { 3169 | name: "storage.type.class.jsdoc" 3170 | match: ''' 3171 | (?x)(? # {Array} or {Object} type application (optional .) 3283 | ) 3284 | (?: 3285 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback 3286 | [a-zA-Z_$]+ 3287 | (?: 3288 | (?: 3289 | [\\w$]* 3290 | (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers 3291 | ) | 3292 | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) 3293 | ) 3294 | )* 3295 | \\) | 3296 | [a-zA-Z_$]+ 3297 | (?: 3298 | (?: 3299 | [\\w$]* 3300 | (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers 3301 | ) | 3302 | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) 3303 | ) 3304 | (?: 3305 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback 3306 | [a-zA-Z_$]+ 3307 | (?: 3308 | [\\w$]* | 3309 | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) 3310 | ) 3311 | )* 3312 | ) 3313 | ) 3314 | # Check for suffix 3315 | (?:\\[\\])? # {string[]} type application, an array of strings 3316 | =? # {string=} optional parameter 3317 | ) 3318 | )}) 3319 | 3320 | \\s+ 3321 | 3322 | ( 3323 | \\[ # [foo] optional parameter 3324 | \\s* 3325 | (?: 3326 | [a-zA-Z_$][\\w$]* 3327 | (?: 3328 | (?:\\[\\])? # Foo[].bar properties within an array 3329 | \\. # Foo.Bar namespaced parameter 3330 | [a-zA-Z_$][\\w$]* 3331 | )* 3332 | (?: 3333 | \\s* 3334 | = # [foo=bar] Default parameter value 3335 | \\s* 3336 | [\\w$\\s]* 3337 | )? 3338 | ) 3339 | \\s* 3340 | \\] | 3341 | (?: 3342 | [a-zA-Z_$][\\w$]* 3343 | (?: 3344 | (?:\\[\\])? # Foo[].bar properties within an array 3345 | \\. # Foo.Bar namespaced parameter 3346 | [a-zA-Z_$][\\w$]* 3347 | )* 3348 | )? 3349 | ) 3350 | 3351 | \\s+ 3352 | 3353 | (?:-\\s+)? # optional hyphen before the description 3354 | 3355 | ((?:(?!\\*\\/).)*) # The type description 3356 | ''' 3357 | captures: 3358 | "0": 3359 | name: "other.meta.jsdoc" 3360 | "1": 3361 | name: "entity.name.type.instance.jsdoc" 3362 | "2": 3363 | name: "variable.other.jsdoc" 3364 | "3": 3365 | name: "other.description.jsdoc" 3366 | } 3367 | { 3368 | match: ''' 3369 | (?x) 3370 | 3371 | ({(?: 3372 | \\* | # {*} any type 3373 | \\? | # {?} unknown type 3374 | 3375 | (?: 3376 | (?: # Check for a prefix 3377 | \\? | # {?string} nullable type 3378 | ! | # {!string} non-nullable type 3379 | \\.{3} # {...string} variable number of parameters 3380 | )? 3381 | 3382 | (?: 3383 | (?: 3384 | function # {function(string, number)} function type 3385 | \\s* 3386 | \\( 3387 | \\s* 3388 | (?: 3389 | [a-zA-Z_$][\\w$]* 3390 | (?: 3391 | \\s*,\\s* 3392 | [a-zA-Z_$][\\w$]* 3393 | )* 3394 | )? 3395 | \\s* 3396 | \\) 3397 | (?: # {function(): string} function return type 3398 | \\s*:\\s* 3399 | [a-zA-Z_$][\\w$]* 3400 | )? 3401 | )? 3402 | | 3403 | (?: 3404 | \\( # Opening bracket of multiple types with parenthesis {(string|number)} 3405 | [a-zA-Z_$]+ 3406 | (?: 3407 | [\\w$]* | 3408 | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) 3409 | ) 3410 | (?: 3411 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback 3412 | [a-zA-Z_$]+ 3413 | (?: 3414 | [\\w$]* | 3415 | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) 3416 | ) 3417 | )* 3418 | \\) | 3419 | [a-zA-Z_$]+ 3420 | (?: 3421 | [\\w$]* | 3422 | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) 3423 | ) 3424 | (?: 3425 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback 3426 | [a-zA-Z_$]+ 3427 | (?: 3428 | [\\w$]* | 3429 | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) 3430 | ) 3431 | )* 3432 | ) 3433 | ) 3434 | # Check for suffix 3435 | (?:\\[\\])? # {string[]} type application, an array of strings 3436 | =? # {string=} optional parameter 3437 | ) 3438 | )}) 3439 | 3440 | \\s+ 3441 | 3442 | (?:-\\s+)? # optional hyphen before the description 3443 | 3444 | ((?:(?!\\*\\/).)*) # The type description 3445 | ''' 3446 | captures: 3447 | "0": 3448 | name: "other.meta.jsdoc" 3449 | "1": 3450 | name: "entity.name.type.instance.jsdoc" 3451 | "2": 3452 | name: "other.description.jsdoc" 3453 | } 3454 | ] 3455 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-typescript-grammars-only", 3 | "version": "1.6.0", 4 | "description": "A grammar only language package for TypeScript", 5 | "keywords": [ 6 | "language", 7 | "grammar", 8 | "typescript" 9 | ], 10 | "repository": "https://github.com/tcarlsen/language-typescript-grammars-only", 11 | "license": "MIT", 12 | "engines": { 13 | "atom": ">=0.174.0 <2.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /settings/language-typescript-grammars-only-tsx.cson: -------------------------------------------------------------------------------- 1 | '.source.tsx': 2 | 'editor': 3 | 'commentStart': '// ' 4 | 'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)' 5 | 'increaseIndentPattern': '(?x) 6 | \\{ [^}"\']* $ 7 | | \\[ [^\\]"\']* $ 8 | | \\( [^)"\']* $ 9 | ' 10 | 'decreaseIndentPattern': '(?x) 11 | ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])] 12 | ' 13 | -------------------------------------------------------------------------------- /settings/language-typescript-grammars-only.cson: -------------------------------------------------------------------------------- 1 | '.source.ts': 2 | 'editor': 3 | 'commentStart': '// ' 4 | 'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)' 5 | 'increaseIndentPattern': '(?x) 6 | \\{ [^}"\']* $ 7 | | \\[ [^\\]"\']* $ 8 | | \\( [^)"\']* $ 9 | ' 10 | 'decreaseIndentPattern': '(?x) 11 | ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])] 12 | ' 13 | -------------------------------------------------------------------------------- /snippets/language-typescript-grammars-only.cson: -------------------------------------------------------------------------------- 1 | '.source.ts, .source.tsx': 2 | 'reference': 3 | 'prefix': 'ref' 4 | 'body': """ 5 | /// 6 | """ 7 | 'AMD module name': 8 | 'prefix': 'amd-mod' 9 | 'body': """ 10 | /// 11 | """ 12 | 'AMD dependency': 13 | 'prefix': 'amd-dep' 14 | 'body': """ 15 | /// 16 | """ 17 | 'import': 18 | 'prefix': 'import' 19 | 'body': """ 20 | import ${2} from "${1:path}";$3 21 | """ 22 | 'importr': 23 | 'prefix': 'importr' 24 | 'body': """ 25 | import ${1} = require("${2}");$3 26 | """ 27 | 'JSDoc single line': 28 | 'prefix': '//' 29 | 'body': """ 30 | /** $1 */ 31 | """ 32 | 'JSDoc multi line': 33 | 'prefix': '///' 34 | 'body': """ 35 | /** 36 | * $1 37 | */ 38 | """ 39 | 'if': 40 | 'prefix': 'if' 41 | 'body': """ 42 | if (${1:true}) { 43 | $2 44 | } 45 | """ 46 | 'ifelse': 47 | 'prefix': 'ifel' 48 | 'body': """ 49 | if (${1:true}) { 50 | $2 51 | } else {} 52 | """ 53 | 'while': 54 | 'prefix': 'while' 55 | 'body': """ 56 | while (${1:true}) { 57 | $2 58 | } 59 | """ 60 | 'interface': 61 | 'prefix': 'interface' 62 | 'body': """ 63 | interface ${1:Name} { 64 | $2 65 | } 66 | """ 67 | 'class': 68 | 'prefix': 'class' 69 | 'body': """ 70 | class ${1:Name} { 71 | $2 72 | } 73 | """ 74 | 'namespace': 75 | 'prefix': 'namespace' 76 | 'body': """ 77 | namespace ${1:name} { 78 | $2 79 | } 80 | """ 81 | 'function': 82 | 'prefix': 'function' 83 | 'body': """ 84 | function ${1:name}(${2:parameter}) { 85 | ${3:throw new Error("Not implemented yet");} 86 | } 87 | """ 88 | 'fatarrow': 89 | 'prefix': 'arr' 90 | 'body': """ 91 | (${1:parameter}) => { ${2:return true;} } 92 | """ 93 | 'for': 94 | 'prefix': 'for' 95 | 'body': """ 96 | for (let ${2:i} = 0; ${2:i} < ${1:array}.length; ${2:i}++) { 97 | ${1:array}[${2:i}]$3; 98 | } 99 | """ 100 | 'forof': 101 | 'prefix': 'forof' 102 | 'body': """ 103 | for (let ${2:variable} of ${1:iterable}) { 104 | $3 105 | } 106 | """ 107 | 'forea': 108 | 'prefix': 'forea' 109 | 'body': """ 110 | forEach(${1:variable} => { 111 | $2 112 | }); 113 | """ 114 | 'forin': 115 | 'prefix': 'forin' 116 | 'body': """ 117 | for (let ${2:key} in ${1:iterable}) { 118 | $3 119 | } 120 | """ 121 | 'externalmodule': 122 | 'prefix': 'declaremodule' 123 | 'body': """ 124 | declare module "$1" { 125 | var $2:${3:any}; 126 | export = $2; 127 | }$4 128 | """ 129 | 'transformer': 130 | 'prefix': 'transform' 131 | 'body': """ 132 | transform:${1:null}{ 133 | $2 134 | }transform:${1:null} 135 | """ 136 | 'shebang': 137 | 'prefix': '#!' 138 | 'body': """ 139 | #!/usr/bin/env node 140 | """ 141 | --------------------------------------------------------------------------------