├── .github └── workflows │ └── ci.yml ├── .gitignore ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE.md ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── grammars ├── TypeScript.json ├── TypeScriptReact.json ├── tree-sitter-flow.cson ├── tree-sitter-tsx.cson └── tree-sitter-typescript.cson ├── lib └── main.js ├── package-lock.json ├── package.json ├── settings ├── TypeScript.cson └── TypeScriptReact.cson └── snippets └── language-typescript.cson /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | env: 6 | CI: true 7 | 8 | jobs: 9 | Test: 10 | strategy: 11 | matrix: 12 | os: [ubuntu-latest, macos-latest, windows-latest] 13 | channel: [stable, beta] 14 | runs-on: ${{ matrix.os }} 15 | steps: 16 | - uses: actions/checkout@v1 17 | - uses: UziTech/action-setup-atom@v2 18 | with: 19 | version: ${{ matrix.channel }} 20 | - name: Install dependencies 21 | run: apm install 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) 2 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ### Prerequisites 10 | 11 | * [ ] Put an X between the brackets on this line if you have done all of the following: 12 | * Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode 13 | * Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/ 14 | * Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq 15 | * Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom 16 | * Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages 17 | 18 | ### Description 19 | 20 | [Description of the issue] 21 | 22 | ### Steps to Reproduce 23 | 24 | 1. [First Step] 25 | 2. [Second Step] 26 | 3. [and so on...] 27 | 28 | **Expected behavior:** [What you expect to happen] 29 | 30 | **Actual behavior:** [What actually happens] 31 | 32 | **Reproduces how often:** [What percentage of the time does it reproduce?] 33 | 34 | ### Versions 35 | 36 | You can get this information from copy and pasting the output of `atom --version` and `apm --version` from the command line. Also, please include the OS and what version of the OS you're running. 37 | 38 | ### Additional Information 39 | 40 | Any additional information, configuration or data that might be necessary to reproduce the issue. 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) Microsoft Corporation 2 | 3 | Copyright (c) 2017 GitHub Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------- 25 | 26 | This package was derived from a TextMate grammar located at 27 | https://github.com/Microsoft/TypeScript-TmLanguage and distributed under the 28 | MIT licence. 29 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Requirements 2 | 3 | * Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. 4 | * All new code requires tests to ensure against regressions 5 | 6 | ### Description of the Change 7 | 8 | 13 | 14 | ### Alternate Designs 15 | 16 | 17 | 18 | ### Benefits 19 | 20 | 21 | 22 | ### Possible Drawbacks 23 | 24 | 25 | 26 | ### Applicable Issues 27 | 28 | 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/) 2 | # TypeScript language support in Atom 3 | [![CI](https://github.com/atom/language-typescript/actions/workflows/ci.yml/badge.svg)](https://github.com/atom/language-typescript/actions/workflows/ci.yml) 4 | 5 | [![Dependency Status](https://david-dm.org/atom/language-typescript.svg)](https://david-dm.org/atom/language-typescript) 6 | 7 | Adds syntax highlighting and snippets for TypeScript in Atom. 8 | 9 | The grammar is the [Microsoft TypeScript TextMate grammar](https://github.com/Microsoft/TypeScript-TmLanguage) and copied here on a semi-regular basis. Any issues relating to syntax highlighting are likely to be there. 10 | -------------------------------------------------------------------------------- /grammars/tree-sitter-flow.cson: -------------------------------------------------------------------------------- 1 | name: 'Flow JavaScript' 2 | scopeName: 'source.flow' 3 | type: 'tree-sitter' 4 | parser: 'tree-sitter-typescript/tsx' 5 | 6 | fileTypes: [ 7 | 'js' 8 | 'flow.js' 9 | 'flow.jsx' 10 | 'js.flow' 11 | 'jsx.flow' 12 | ] 13 | 14 | contentRegex: '(/\\*([^*]|\\*[^/])*|//.*)(@flow|flow-typed)\\b' 15 | 16 | comments: 17 | start: '// ' 18 | 19 | folds: [ 20 | { 21 | type: 'comment' 22 | } 23 | { 24 | type: ['jsx_element', 'template_string'] 25 | start: {index: 0} 26 | end: {index: -1} 27 | } 28 | { 29 | type: 'jsx_self_closing_element' 30 | start: {index: 1} 31 | end: {index: -2} 32 | } 33 | { 34 | type: [ 35 | 'object_type' 36 | 'type_arguments' 37 | 'type_parameters' 38 | ] 39 | start: {index: 0} 40 | end: {index: -1} 41 | } 42 | { 43 | start: {index: 0, type: '{'} 44 | end: {index: -1, type: '}'} 45 | } 46 | { 47 | start: {index: 0, type: '['} 48 | end: {index: -1, type: ']'} 49 | } 50 | { 51 | start: {index: 0, type: '('} 52 | end: {index: -1, type: ')'} 53 | } 54 | ] 55 | 56 | scopes: 57 | 'program': 'source.flow' 58 | 59 | 'property_identifier': [ 60 | { 61 | match: '^[\$A-Z_]+$', 62 | scopes: 'constant.other.property.js' 63 | } 64 | 65 | 'variable.other.object.property' 66 | ] 67 | 68 | 'shorthand_property_identifier': [ 69 | { 70 | match: '^[\$A-Z_]{2,}$', 71 | scopes: 'constant.other' 72 | } 73 | ] 74 | 75 | ' 76 | class > identifier, 77 | new_expression > call_expression > identifier 78 | ': 'support.type' 79 | 80 | ' 81 | jsx_opening_element > identifier, 82 | jsx_closing_element > identifier, 83 | jsx_self_closing_element > identifier, 84 | call_expression > identifier 85 | ': [ 86 | { 87 | match: '^[A-Z]', 88 | scopes: 'support.type' 89 | }, 90 | ] 91 | 92 | 'function > identifier': 'entity.name.function' 93 | 'generator_function > identifier': 'entity.name.function' 94 | 95 | 'call_expression > identifier': [ 96 | {match: '^require$', scopes: 'support.function'}, 97 | 'entity.name.function' 98 | ] 99 | 100 | 'call_expression > super': 'support.function.super' 101 | 102 | 'method_definition > property_identifier': 'entity.name.function' 103 | 'call_expression > member_expression > property_identifier': 'entity.name.function' 104 | 105 | 'identifier': [ 106 | { 107 | match: '^(global|module|exports|__filename|__dirname|window|document)$', 108 | scopes: 'support.variable' 109 | }, 110 | { 111 | exact: 'require', scopes: 'support.function' 112 | } 113 | { 114 | match: '^[\$A-Z_]{2,}$', 115 | scopes: 'constant.other' 116 | }, 117 | { 118 | match: '^[A-Z]', 119 | scopes: 'support.type' 120 | }, 121 | ] 122 | 123 | 'number': 'constant.numeric' 124 | 'string': 'string.quoted' 125 | 'regex': 'string.regexp' 126 | 'escape_sequence': 'constant.character.escape' 127 | 'template_string': 'string.quoted.template' 128 | 'undefined': 'constant.language' 129 | 'null': 'constant.language.null' 130 | 'true': 'constant.language.boolean.true' 131 | 'false': 'constant.language.boolean.false' 132 | 'comment': 'comment.block' 133 | 'hash_bang_line': 'comment.block' 134 | 135 | ' 136 | jsx_expression > "{", 137 | jsx_expression > "}", 138 | template_substitution > "${", 139 | template_substitution > "}" 140 | ': 'punctuation.section.embedded' 141 | 'template_substitution': 'embedded.source' 142 | 143 | '"("': 'punctuation.definition.parameters.begin.bracket.round' 144 | '")"': 'punctuation.definition.parameters.end.bracket.round' 145 | '"{"': 'punctuation.definition.function.body.begin.bracket.curly' 146 | '"}"': 'punctuation.definition.function.body.end.bracket.curly' 147 | '";"': 'punctuation.terminator.statement.semicolon' 148 | '"["': 'punctuation.definition.array.begin.bracket.square' 149 | '"]"': 'punctuation.definition.array.end.bracket.square' 150 | 151 | '"var"': 'storage.type' 152 | '"let"': 'storage.type' 153 | '"class"': 'storage.type' 154 | '"extends"': 'storage.modifier' 155 | '"const"': 'storage.modifier' 156 | '"static"': 'storage.modifier' 157 | '"function"': 'storage.type.function' 158 | '"=>"': 'storage.type.function.arrow' 159 | 160 | '"="': 'keyword.operator.js' 161 | '"+="': 'keyword.operator.js' 162 | '"-="': 'keyword.operator.js' 163 | '"*="': 'keyword.operator.js' 164 | '"/="': 'keyword.operator.js' 165 | '"%="': 'keyword.operator.js' 166 | '"<<="': 'keyword.operator.js' 167 | '">>="': 'keyword.operator.js' 168 | '">>>="': 'keyword.operator.js' 169 | '"&="': 'keyword.operator.js' 170 | '"^="': 'keyword.operator.js' 171 | '"|="': 'keyword.operator.js' 172 | '"!"': 'keyword.operator.js' 173 | '"+"': 'keyword.operator.js' 174 | '"-"': 'keyword.operator.js' 175 | '"*"': 'keyword.operator.js' 176 | '"/"': 'keyword.operator.js' 177 | '"%"': 'keyword.operator.js' 178 | '"=="': 'keyword.operator.js' 179 | '"==="': 'keyword.operator.js' 180 | '"!="': 'keyword.operator.js' 181 | '"!=="': 'keyword.operator.js' 182 | '">="': 'keyword.operator.js' 183 | '"<="': 'keyword.operator.js' 184 | '">"': 'keyword.operator.js' 185 | '"<"': 'keyword.operator.js' 186 | '":"': 'keyword.operator.js' 187 | '"?"': 'keyword.operator.js' 188 | '"&&"': 'keyword.operator.js' 189 | '"||"': 'keyword.operator.js' 190 | '"&"': 'keyword.operator.js' 191 | '"~"': 'keyword.operator.js' 192 | '"^"': 'keyword.operator.js' 193 | '">>"': 'keyword.operator.js' 194 | '">>>"': 'keyword.operator.js' 195 | '"<<"': 'keyword.operator.js' 196 | '"|"': 'keyword.operator.js' 197 | '"++"': 'keyword.operator.js' 198 | '"--"': 'keyword.operator.js' 199 | '"..."': 'keyword.operator.js' 200 | 201 | '"in"': 'keyword.control' 202 | '"instanceof"': 'keyword.control' 203 | '"of"': 'keyword.control' 204 | '"new"': 'keyword.control' 205 | '"typeof"': 'keyword.control' 206 | 207 | '"get"': 'keyword.operator.setter' 208 | '"set"': 'keyword.operator.setter' 209 | 210 | '"."': 'meta.delimiter.period' 211 | '","': 'meta.delimiter.comma' 212 | 213 | '"as"': 'keyword.modifier' 214 | '"if"': 'keyword.control' 215 | '"do"': 'keyword.control' 216 | '"else"': 'keyword.control' 217 | '"while"': 'keyword.control' 218 | '"for"': 'keyword.control' 219 | '"return"': 'keyword.control' 220 | '"break"': 'keyword.control' 221 | '"continue"': 'keyword.control' 222 | '"throw"': 'keyword.control' 223 | '"try"': 'keyword.control' 224 | '"catch"': 'keyword.control' 225 | '"finally"': 'keyword.control' 226 | '"switch"': 'keyword.control' 227 | '"case"': 'keyword.control' 228 | '"default"': 'keyword.control' 229 | '"export"': 'keyword.control' 230 | '"import"': 'keyword.control' 231 | '"from"': 'keyword.control' 232 | '"yield"': 'keyword.control' 233 | '"async"': 'keyword.control' 234 | '"await"': 'keyword.control' 235 | '"debugger"': 'keyword.control' 236 | '"delete"': 'keyword.control' 237 | 238 | 'jsx_attribute > property_identifier': 'entity.other.attribute-name' 239 | 'jsx_opening_element > identifier': 'entity.name.tag' 240 | 'jsx_closing_element > identifier': 'entity.name.tag' 241 | 'jsx_self_closing_element > identifier': 'entity.name.tag' 242 | 243 | 'class > identifier': 'support.storage.type' 244 | 'type_identifier': 'support.storage.type' 245 | 'predefined_type': 'support.storage.type' 246 | 247 | ' 248 | method_signature > property_identifier, 249 | function_signature > identifier 250 | ': 'entity.name.function' 251 | 252 | '"implements"': 'keyword.modifier' 253 | '"namespace"': 'keyword.modifier' 254 | '"enum"': 'keyword.modifier' 255 | '"interface"': 'keyword.modifier' 256 | '"module"': 'keyword.modifier' 257 | '"declare"': 'keyword.modifier' 258 | '"public"': 'keyword.modifier' 259 | '"private"': 'keyword.modifier' 260 | '"protected"': 'keyword.modifier' 261 | 'readonly': 'keyword.modifier' 262 | '"type"': 'keyword.modifier' 263 | -------------------------------------------------------------------------------- /grammars/tree-sitter-tsx.cson: -------------------------------------------------------------------------------- 1 | name: 'TypeScriptReact' 2 | scopeName: 'source.tsx' 3 | type: 'tree-sitter' 4 | parser: 'tree-sitter-typescript/tsx' 5 | 6 | fileTypes: ['tsx'] 7 | 8 | comments: 9 | start: '// ' 10 | 11 | folds: [ 12 | { 13 | type: 'comment' 14 | } 15 | { 16 | type: ['jsx_element', 'template_string'] 17 | start: {index: 0} 18 | end: {index: -1} 19 | } 20 | { 21 | type: 'jsx_self_closing_element' 22 | start: {index: 1} 23 | end: {index: -2} 24 | } 25 | { 26 | type: [ 27 | 'object_type' 28 | 'type_arguments' 29 | 'type_parameters' 30 | ] 31 | start: {index: 0} 32 | end: {index: -1} 33 | } 34 | { 35 | start: {index: 0, type: '{'} 36 | end: {index: -1, type: '}'} 37 | } 38 | { 39 | start: {index: 0, type: '['} 40 | end: {index: -1, type: ']'} 41 | } 42 | { 43 | start: {index: 0, type: '('} 44 | end: {index: -1, type: ')'} 45 | } 46 | ] 47 | 48 | scopes: 49 | 'program': 'source.ts' 50 | 51 | 'property_identifier': [ 52 | { 53 | match: '^[\$A-Z_]+$', 54 | scopes: 'constant.other.property.js' 55 | } 56 | 57 | 'variable.other.object.property' 58 | ] 59 | 60 | 'shorthand_property_identifier': [ 61 | { 62 | match: '^[\$A-Z_]{2,}$', 63 | scopes: 'constant.other' 64 | } 65 | ] 66 | 67 | ' 68 | class > identifier, 69 | new_expression > call_expression > identifier 70 | ': 'support.type' 71 | 72 | ' 73 | jsx_opening_element > identifier, 74 | jsx_closing_element > identifier, 75 | jsx_self_closing_element > identifier, 76 | call_expression > identifier 77 | ': [ 78 | { 79 | match: '^[A-Z]', 80 | scopes: 'support.type' 81 | }, 82 | ] 83 | 84 | 'function > identifier': 'entity.name.function' 85 | 'generator_function > identifier': 'entity.name.function' 86 | 87 | 'call_expression > identifier': [ 88 | {match: '^require$', scopes: 'support.function'}, 89 | 'entity.name.function' 90 | ] 91 | 92 | 'call_expression > super': 'support.function.super' 93 | 94 | 'method_definition > property_identifier': 'entity.name.function' 95 | 'call_expression > member_expression > property_identifier': 'entity.name.function' 96 | 97 | 'identifier': [ 98 | { 99 | match: '^(global|module|exports|__filename|__dirname|window|document)$', 100 | scopes: 'support.variable' 101 | }, 102 | { 103 | exact: 'require', scopes: 'support.function' 104 | } 105 | { 106 | match: '^[\$A-Z_]{2,}$', 107 | scopes: 'constant.other' 108 | }, 109 | { 110 | match: '^[A-Z]', 111 | scopes: 'support.type' 112 | }, 113 | ] 114 | 115 | 'number': 'constant.numeric' 116 | 'string': 'string.quoted' 117 | 'regex': 'string.regexp' 118 | 'escape_sequence': 'constant.character.escape' 119 | 'template_string': 'string.quoted.template' 120 | 'undefined': 'constant.language' 121 | 'null': 'constant.language.null' 122 | 'true': 'constant.language.boolean.true' 123 | 'false': 'constant.language.boolean.false' 124 | 'comment': 'comment.block' 125 | 'hash_bang_line': 'comment.block' 126 | 127 | ' 128 | jsx_expression > "{", 129 | jsx_expression > "}", 130 | template_substitution > "${", 131 | template_substitution > "}" 132 | ': 'punctuation.section.embedded' 133 | 'template_substitution': 'embedded.source' 134 | 135 | '"("': 'punctuation.definition.parameters.begin.bracket.round' 136 | '")"': 'punctuation.definition.parameters.end.bracket.round' 137 | '"{"': 'punctuation.definition.function.body.begin.bracket.curly' 138 | '"}"': 'punctuation.definition.function.body.end.bracket.curly' 139 | '";"': 'punctuation.terminator.statement.semicolon' 140 | '"["': 'punctuation.definition.array.begin.bracket.square' 141 | '"]"': 'punctuation.definition.array.end.bracket.square' 142 | 143 | '"var"': 'storage.type' 144 | '"let"': 'storage.type' 145 | '"class"': 'storage.type' 146 | '"extends"': 'storage.modifier' 147 | '"const"': 'storage.modifier' 148 | '"static"': 'storage.modifier' 149 | '"function"': 'storage.type.function' 150 | '"=>"': 'storage.type.function.arrow' 151 | 152 | '"="': 'keyword.operator.js' 153 | '"+="': 'keyword.operator.js' 154 | '"-="': 'keyword.operator.js' 155 | '"*="': 'keyword.operator.js' 156 | '"/="': 'keyword.operator.js' 157 | '"%="': 'keyword.operator.js' 158 | '"<<="': 'keyword.operator.js' 159 | '">>="': 'keyword.operator.js' 160 | '">>>="': 'keyword.operator.js' 161 | '"&="': 'keyword.operator.js' 162 | '"^="': 'keyword.operator.js' 163 | '"|="': 'keyword.operator.js' 164 | '"!"': 'keyword.operator.js' 165 | '"+"': 'keyword.operator.js' 166 | '"-"': 'keyword.operator.js' 167 | '"*"': 'keyword.operator.js' 168 | '"/"': 'keyword.operator.js' 169 | '"%"': 'keyword.operator.js' 170 | '"=="': 'keyword.operator.js' 171 | '"==="': 'keyword.operator.js' 172 | '"!="': 'keyword.operator.js' 173 | '"!=="': 'keyword.operator.js' 174 | '">="': 'keyword.operator.js' 175 | '"<="': 'keyword.operator.js' 176 | '">"': 'keyword.operator.js' 177 | '"<"': 'keyword.operator.js' 178 | '":"': 'keyword.operator.js' 179 | '"?"': 'keyword.operator.js' 180 | '"&&"': 'keyword.operator.js' 181 | '"||"': 'keyword.operator.js' 182 | '"&"': 'keyword.operator.js' 183 | '"~"': 'keyword.operator.js' 184 | '"^"': 'keyword.operator.js' 185 | '">>"': 'keyword.operator.js' 186 | '">>>"': 'keyword.operator.js' 187 | '"<<"': 'keyword.operator.js' 188 | '"|"': 'keyword.operator.js' 189 | '"++"': 'keyword.operator.js' 190 | '"--"': 'keyword.operator.js' 191 | '"..."': 'keyword.operator.js' 192 | 193 | '"in"': 'keyword.control' 194 | '"instanceof"': 'keyword.control' 195 | '"of"': 'keyword.control' 196 | '"new"': 'keyword.control' 197 | '"typeof"': 'keyword.control' 198 | 199 | '"get"': 'keyword.operator.setter' 200 | '"set"': 'keyword.operator.setter' 201 | 202 | '"."': 'meta.delimiter.period' 203 | '","': 'meta.delimiter.comma' 204 | 205 | '"as"': 'keyword.control' 206 | '"if"': 'keyword.control' 207 | '"do"': 'keyword.control' 208 | '"else"': 'keyword.control' 209 | '"while"': 'keyword.control' 210 | '"for"': 'keyword.control' 211 | '"return"': 'keyword.control' 212 | '"break"': 'keyword.control' 213 | '"continue"': 'keyword.control' 214 | '"throw"': 'keyword.control' 215 | '"try"': 'keyword.control' 216 | '"catch"': 'keyword.control' 217 | '"finally"': 'keyword.control' 218 | '"switch"': 'keyword.control' 219 | '"case"': 'keyword.control' 220 | '"default"': 'keyword.control' 221 | '"export"': 'keyword.control' 222 | '"import"': 'keyword.control' 223 | '"from"': 'keyword.control' 224 | '"yield"': 'keyword.control' 225 | '"async"': 'keyword.control' 226 | '"await"': 'keyword.control' 227 | '"debugger"': 'keyword.control' 228 | '"delete"': 'keyword.control' 229 | 230 | 'jsx_attribute > property_identifier': 'entity.other.attribute-name' 231 | 'jsx_opening_element > identifier': 'entity.name.tag' 232 | 'jsx_closing_element > identifier': 'entity.name.tag' 233 | 'jsx_self_closing_element > identifier': 'entity.name.tag' 234 | 235 | 'class > identifier': 'support.storage.type' 236 | 'type_identifier': 'support.storage.type' 237 | 'predefined_type': 'support.storage.type' 238 | 239 | ' 240 | method_signature > property_identifier, 241 | function_signature > identifier 242 | ': 'entity.name.function' 243 | 244 | '"implements"': 'keyword.modifier' 245 | '"namespace"': 'keyword.modifier' 246 | '"enum"': 'keyword.modifier' 247 | '"interface"': 'keyword.modifier' 248 | '"module"': 'keyword.modifier' 249 | '"declare"': 'keyword.modifier' 250 | '"public"': 'keyword.modifier' 251 | '"private"': 'keyword.modifier' 252 | '"protected"': 'keyword.modifier' 253 | 'readonly': 'keyword.modifier' 254 | '"type"': 'keyword.modifier' 255 | -------------------------------------------------------------------------------- /grammars/tree-sitter-typescript.cson: -------------------------------------------------------------------------------- 1 | name: 'TypeScript' 2 | scopeName: 'source.ts' 3 | type: 'tree-sitter' 4 | parser: 'tree-sitter-typescript/typescript' 5 | 6 | fileTypes: ['ts'] 7 | 8 | comments: 9 | start: '// ' 10 | 11 | folds: [ 12 | { 13 | type: 'comment' 14 | } 15 | { 16 | type: [ 17 | 'object_type' 18 | 'type_arguments' 19 | 'type_parameters' 20 | ] 21 | start: {index: 0} 22 | end: {index: -1} 23 | } 24 | { 25 | start: {index: 0, type: '{'} 26 | end: {index: -1, type: '}'} 27 | } 28 | { 29 | start: {index: 0, type: '['} 30 | end: {index: -1, type: ']'} 31 | } 32 | { 33 | start: {index: 0, type: '('} 34 | end: {index: -1, type: ')'} 35 | } 36 | ] 37 | 38 | scopes: 39 | 'program': 'source.ts' 40 | 41 | 'property_identifier': [ 42 | { 43 | match: '^[\$A-Z_]+$', 44 | scopes: 'constant.other.property.js' 45 | } 46 | 47 | 'variable.other.object.property' 48 | ] 49 | 50 | 'shorthand_property_identifier': [ 51 | { 52 | match: '^[\$A-Z_]{2,}$', 53 | scopes: 'constant.other' 54 | } 55 | ] 56 | 57 | ' 58 | class > identifier, 59 | new_expression > call_expression > identifier 60 | ': 'support.type' 61 | 62 | ' 63 | call_expression > identifier 64 | ': [ 65 | { 66 | match: '^[A-Z]', 67 | scopes: 'support.type' 68 | }, 69 | ] 70 | 71 | 'function > identifier': 'entity.name.function' 72 | 'generator_function > identifier': 'entity.name.function' 73 | 74 | 'call_expression > identifier': [ 75 | {match: '^require$', scopes: 'support.function'}, 76 | 'entity.name.function' 77 | ] 78 | 79 | 'call_expression > super': 'support.function.super' 80 | 81 | 'method_definition > property_identifier': 'entity.name.function' 82 | 'call_expression > member_expression > property_identifier': 'entity.name.function' 83 | 84 | 'identifier': [ 85 | { 86 | match: '^(global|module|exports|__filename|__dirname|window|document)$', 87 | scopes: 'support.variable' 88 | }, 89 | { 90 | exact: 'require', scopes: 'support.function' 91 | } 92 | { 93 | match: '^[\$A-Z_]{2,}$', 94 | scopes: 'constant.other' 95 | }, 96 | { 97 | match: '^[A-Z]', 98 | scopes: 'support.type' 99 | }, 100 | ] 101 | 102 | 'number': 'constant.numeric' 103 | 'string': 'string.quoted' 104 | 'regex': 'string.regexp' 105 | 'escape_sequence': 'constant.character.escape' 106 | 'template_string': 'string.quoted.template' 107 | 'undefined': 'constant.language' 108 | 'null': 'constant.language.null' 109 | 'true': 'constant.language.boolean.true' 110 | 'false': 'constant.language.boolean.false' 111 | 'comment': 'comment.block' 112 | 'hash_bang_line': 'comment.block' 113 | 114 | ' 115 | template_substitution > "${", 116 | template_substitution > "}" 117 | ': 'punctuation.section.embedded' 118 | 'template_substitution': 'embedded.source' 119 | 120 | '"("': 'punctuation.definition.parameters.begin.bracket.round' 121 | '")"': 'punctuation.definition.parameters.end.bracket.round' 122 | '"{"': 'punctuation.definition.function.body.begin.bracket.curly' 123 | '"}"': 'punctuation.definition.function.body.end.bracket.curly' 124 | '";"': 'punctuation.terminator.statement.semicolon' 125 | '"["': 'punctuation.definition.array.begin.bracket.square' 126 | '"]"': 'punctuation.definition.array.end.bracket.square' 127 | 128 | '"var"': 'storage.type' 129 | '"let"': 'storage.type' 130 | '"class"': 'storage.type' 131 | '"extends"': 'storage.modifier' 132 | '"const"': 'storage.modifier' 133 | '"static"': 'storage.modifier' 134 | '"function"': 'storage.type.function' 135 | '"=>"': 'storage.type.function.arrow' 136 | 137 | '"="': 'keyword.operator.js' 138 | '"+="': 'keyword.operator.js' 139 | '"-="': 'keyword.operator.js' 140 | '"*="': 'keyword.operator.js' 141 | '"/="': 'keyword.operator.js' 142 | '"%="': 'keyword.operator.js' 143 | '"<<="': 'keyword.operator.js' 144 | '">>="': 'keyword.operator.js' 145 | '">>>="': 'keyword.operator.js' 146 | '"&="': 'keyword.operator.js' 147 | '"^="': 'keyword.operator.js' 148 | '"|="': 'keyword.operator.js' 149 | '"!"': 'keyword.operator.js' 150 | '"+"': 'keyword.operator.js' 151 | '"-"': 'keyword.operator.js' 152 | '"*"': 'keyword.operator.js' 153 | '"/"': 'keyword.operator.js' 154 | '"%"': 'keyword.operator.js' 155 | '"=="': 'keyword.operator.js' 156 | '"==="': 'keyword.operator.js' 157 | '"!="': 'keyword.operator.js' 158 | '"!=="': 'keyword.operator.js' 159 | '">="': 'keyword.operator.js' 160 | '"<="': 'keyword.operator.js' 161 | '">"': 'keyword.operator.js' 162 | '"<"': 'keyword.operator.js' 163 | '":"': 'keyword.operator.js' 164 | '"?"': 'keyword.operator.js' 165 | '"&&"': 'keyword.operator.js' 166 | '"||"': 'keyword.operator.js' 167 | '"&"': 'keyword.operator.js' 168 | '"~"': 'keyword.operator.js' 169 | '"^"': 'keyword.operator.js' 170 | '">>"': 'keyword.operator.js' 171 | '">>>"': 'keyword.operator.js' 172 | '"<<"': 'keyword.operator.js' 173 | '"|"': 'keyword.operator.js' 174 | '"++"': 'keyword.operator.js' 175 | '"--"': 'keyword.operator.js' 176 | '"..."': 'keyword.operator.js' 177 | 178 | '"in"': 'keyword.control' 179 | '"instanceof"': 'keyword.control' 180 | '"of"': 'keyword.control' 181 | '"new"': 'keyword.control' 182 | '"typeof"': 'keyword.control' 183 | 184 | '"get"': 'keyword.operator.setter' 185 | '"set"': 'keyword.operator.setter' 186 | 187 | '"."': 'meta.delimiter.period' 188 | '","': 'meta.delimiter.comma' 189 | 190 | '"as"': 'keyword.control' 191 | '"if"': 'keyword.control' 192 | '"do"': 'keyword.control' 193 | '"else"': 'keyword.control' 194 | '"while"': 'keyword.control' 195 | '"for"': 'keyword.control' 196 | '"return"': 'keyword.control' 197 | '"break"': 'keyword.control' 198 | '"continue"': 'keyword.control' 199 | '"throw"': 'keyword.control' 200 | '"try"': 'keyword.control' 201 | '"catch"': 'keyword.control' 202 | '"finally"': 'keyword.control' 203 | '"switch"': 'keyword.control' 204 | '"case"': 'keyword.control' 205 | '"default"': 'keyword.control' 206 | '"export"': 'keyword.control' 207 | '"import"': 'keyword.control' 208 | '"from"': 'keyword.control' 209 | '"yield"': 'keyword.control' 210 | '"async"': 'keyword.control' 211 | '"await"': 'keyword.control' 212 | '"debugger"': 'keyword.control' 213 | '"delete"': 'keyword.control' 214 | 215 | 'class > identifier': 'support.storage.type' 216 | 'type_identifier': 'support.storage.type' 217 | 'predefined_type': 'support.storage.type' 218 | 219 | ' 220 | method_signature > property_identifier, 221 | function_signature > identifier 222 | ': 'entity.name.function' 223 | 224 | '"implements"': 'keyword.modifier' 225 | '"namespace"': 'keyword.modifier' 226 | '"enum"': 'keyword.modifier' 227 | '"interface"': 'keyword.modifier' 228 | '"module"': 'keyword.modifier' 229 | '"declare"': 'keyword.modifier' 230 | '"public"': 'keyword.modifier' 231 | '"private"': 'keyword.modifier' 232 | '"protected"': 'keyword.modifier' 233 | 'readonly': 'keyword.modifier' 234 | '"type"': 'keyword.modifier' 235 | -------------------------------------------------------------------------------- /lib/main.js: -------------------------------------------------------------------------------- 1 | exports.activate = function () { 2 | for (const scopeName of ['source.ts', 'source.flow']) { 3 | atom.grammars.addInjectionPoint(scopeName, { 4 | type: 'call_expression', 5 | 6 | language (callExpression) { 7 | const {firstChild} = callExpression 8 | switch (firstChild.type) { 9 | case 'identifier': 10 | return languageStringForTemplateTag(firstChild.text) 11 | case 'member_expression': 12 | if (firstChild.startPosition.row === firstChild.endPosition.row) { 13 | return languageStringForTemplateTag(firstChild.text) 14 | } 15 | } 16 | }, 17 | 18 | content (callExpression) { 19 | const {lastChild} = callExpression 20 | if (lastChild.type === 'template_string') { 21 | return lastChild 22 | } 23 | } 24 | }) 25 | 26 | atom.grammars.addInjectionPoint(scopeName, { 27 | type: 'assignment_expression', 28 | 29 | language (callExpression) { 30 | const {firstChild} = callExpression 31 | if (firstChild.type === 'member_expression') { 32 | if (firstChild.lastChild.text === 'innerHTML') { 33 | return 'html' 34 | } 35 | } 36 | }, 37 | 38 | content (callExpression) { 39 | const {lastChild} = callExpression 40 | if (lastChild.type === 'template_string') { 41 | return lastChild 42 | } 43 | } 44 | }) 45 | 46 | atom.grammars.addInjectionPoint(scopeName, { 47 | type: 'regex_pattern', 48 | language (regex) { return 'regex' }, 49 | content (regex) { return regex } 50 | }) 51 | } 52 | } 53 | 54 | const STYLED_REGEX = /\bstyled\b/i 55 | 56 | function languageStringForTemplateTag (tag) { 57 | if (STYLED_REGEX.test(tag)) { 58 | return 'CSS' 59 | } else { 60 | return tag 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-typescript", 3 | "version": "0.6.3", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "nan": { 8 | "version": "2.14.0", 9 | "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", 10 | "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" 11 | }, 12 | "tree-sitter-typescript": { 13 | "version": "0.16.1", 14 | "resolved": "https://registry.npmjs.org/tree-sitter-typescript/-/tree-sitter-typescript-0.16.1.tgz", 15 | "integrity": "sha512-jyU5yl4W6JPn66v2YbzaO1ClDcdDnj+7YQNZz3STgEiUooSjpWI1Ucgw+S/qEGbf0fMXsC0fucpP+/M1uc9ubw==", 16 | "requires": { 17 | "nan": "^2.14.0" 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-typescript", 3 | "version": "0.6.3", 4 | "description": "TypeScript language support in Atom", 5 | "keywords": [ 6 | "tree-sitter" 7 | ], 8 | "engines": { 9 | "atom": ">=1.19.1", 10 | "node": "*" 11 | }, 12 | "main": "lib/main", 13 | "homepage": "https://atom.io/packages/language-typescript", 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/atom/language-typescript.git" 17 | }, 18 | "license": "MIT", 19 | "bugs": { 20 | "url": "https://github.com/atom/language-typescript/issues" 21 | }, 22 | "dependencies": { 23 | "tree-sitter-typescript": "^0.16.1" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /settings/TypeScript.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 | -------------------------------------------------------------------------------- /settings/TypeScriptReact.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 | 14 | '.meta.tag.tsx': 15 | 'editor': 16 | 'commentStart': '{/* ', 17 | 'commentEnd': ' */}', 18 | 'increaseIndentPattern': "{[^}\"']*$|\\[[^\\]\"']*$|\\([^)\"']*$|<[a-zA-Z][^/]*$|^\\s*>$", 19 | 'decreaseIndentPattern': "^\\s*(\\s*/[*].*[*]/\\s*)*[}\\])]|^\\s*()" -------------------------------------------------------------------------------- /snippets/language-typescript.cson: -------------------------------------------------------------------------------- 1 | '.source.ts, .source.tsx': 2 | Constructor: 3 | prefix: 'ctor' 4 | body: """ 5 | /** 6 | * 7 | */ 8 | constructor() { 9 | \tsuper(); 10 | \t$0 11 | } 12 | """ 13 | description: 'Constructor' 14 | 'Class Definition': 15 | prefix: 'class' 16 | body: """ 17 | class ${1:name} { 18 | \tconstructor(${2:parameters}) { 19 | \t\t$0 20 | \t} 21 | } 22 | """ 23 | description: 'Class Definition' 24 | 'Public Method Definition': 25 | prefix: 'public method' 26 | body: """ 27 | /** 28 | * ${1:name} 29 | */ 30 | public ${1:name}() { 31 | \t$0 32 | } 33 | """ 34 | description: 'Public Method Definition' 35 | 'Private Method Definition': 36 | prefix: 'private method' 37 | body: """ 38 | private ${1:name}() { 39 | \t$0 40 | } 41 | """ 42 | description: 'Private Method Definition' 43 | 'Import external module.': 44 | prefix: 'import statement' 45 | body: 'import { $0 } from "${1:module}";' 46 | description: 'Import external module.' 47 | 'Property getter': 48 | prefix: 'get' 49 | body: """ 50 | public get ${1:value}() : ${2:string} { 51 | \t${3:return $0} 52 | } 53 | """ 54 | description: 'Property getter' 55 | 'Log to the console': 56 | prefix: 'log' 57 | body: """ 58 | console.log($1); 59 | $0 60 | """ 61 | description: 'Log to the console' 62 | 'Define a full property': 63 | prefix: 'prop' 64 | body: """ 65 | private _${1:value} : ${2:string}; 66 | public get ${1:value}() : ${2:string} { 67 | \treturn this._${1:value}; 68 | } 69 | public set ${1:value}(v : ${2:string}) { 70 | \tthis._${1:value} = v; 71 | } 72 | """ 73 | description: 'Define a full property' 74 | 'Triple-slash reference': 75 | prefix: 'ref' 76 | body: """ 77 | /// 78 | $0 79 | """ 80 | description: 'Triple-slash reference' 81 | 'Return false': 82 | prefix: 'ret0' 83 | body: 'return false;$0' 84 | description: 'Return false' 85 | 'Return true': 86 | prefix: 'ret1' 87 | body: """ 88 | return true;$0 89 | """ 90 | description: 'Return true' 91 | 'Return statement': 92 | prefix: 'ret' 93 | body: 'return $1;$0' 94 | description: 'Return statement' 95 | 'Property setter': 96 | prefix: 'set' 97 | body: """ 98 | public set ${1:value}(v : ${2:string}) { 99 | \tthis.$3 = v; 100 | } 101 | """ 102 | description: 'Property setter' 103 | 'Throw Exception': 104 | prefix: 'throw' 105 | body: """ 106 | throw "$1"; 107 | $0 108 | """ 109 | description: 'Throw Exception' 110 | 'For Loop': 111 | prefix: 'for' 112 | body: """ 113 | for (let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) { 114 | \tconst ${3:element} = ${2:array}[${1:index}]; 115 | \t$0 116 | } 117 | """ 118 | description: 'For Loop' 119 | 'For-Each Loop using =>': 120 | prefix: 'foreach =>' 121 | body: """ 122 | ${1:array}.forEach(${2:element} => { 123 | \t$0 124 | }); 125 | """ 126 | description: 'For-Each Loop using =>' 127 | 'For-In Loop': 128 | prefix: 'forin' 129 | body: """ 130 | for (const ${1:key} in ${2:object}) { 131 | \tif (${2:object}.hasOwnProperty(${1:key})) { 132 | \t\tconst ${3:element} = ${2:object}[${1:key}]; 133 | \t\t$0 134 | \t} 135 | } 136 | """ 137 | description: 'For-In Loop' 138 | 'For-Of Loop': 139 | prefix: 'forof' 140 | body: """ 141 | for (const ${1:iterator} of ${2:object}) { 142 | \t$0 143 | } 144 | """ 145 | description: 'For-Of Loop' 146 | 'Function Statement': 147 | prefix: 'function' 148 | body: """ 149 | function ${1:name}(${2:params}:${3:type}) { 150 | \t$0 151 | } 152 | """ 153 | description: 'Function Statement' 154 | 'If Statement': 155 | prefix: 'if' 156 | body: """ 157 | if (${1:condition}) { 158 | \t$0 159 | } 160 | """ 161 | description: 'If Statement' 162 | 'If-Else Statement': 163 | prefix: 'ifelse' 164 | body: """ 165 | if (${1:condition}) { 166 | \t$0 167 | } else { 168 | \t 169 | } 170 | """ 171 | description: 'If-Else Statement' 172 | 'New Statement': 173 | prefix: 'new' 174 | body: 'const ${1:name} = new ${2:type}(${3:arguments});$0' 175 | description: 'New Statement' 176 | 'Switch Statement': 177 | prefix: 'switch' 178 | body: """ 179 | switch (${1:key}) { 180 | \tcase ${2:value}: 181 | \t\t$0 182 | \t\tbreak; 183 | 184 | \tdefault: 185 | \t\tbreak; 186 | } 187 | """ 188 | description: 'Switch Statement' 189 | 'While Statement': 190 | prefix: 'while' 191 | body: """ 192 | while (${1:condition}) { 193 | \t$0 194 | } 195 | """ 196 | description: 'While Statement' 197 | 'Do-While Statement': 198 | prefix: 'dowhile' 199 | body: """ 200 | do { 201 | \t$0 202 | } while (${1:condition}); 203 | """ 204 | description: 'Do-While Statement' 205 | 'Try-Catch Statement': 206 | prefix: 'trycatch' 207 | body: """ 208 | try { 209 | \t$0 210 | } catch (${1:error}) { 211 | \t 212 | } 213 | """ 214 | description: 'Try-Catch Statement' 215 | 'Set Timeout Function': 216 | prefix: 'settimeout' 217 | body: """ 218 | setTimeout(() => { 219 | \t$0 220 | }, ${1:timeout}); 221 | """ 222 | description: 'Set Timeout Function' 223 | --------------------------------------------------------------------------------