From 034c6f7c451cf1f6eedd4097c61dc4900020317c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 1 Dec 2017 09:40:34 -0800 Subject: [PATCH 01/11] Add tree-sitter TypeScript and Flow grammars --- grammars/tree-sitter-flow.cson | 116 +++++++++++++++++++++++++++ grammars/tree-sitter-typescript.cson | 110 +++++++++++++++++++++++++ package.json | 3 + 3 files changed, 229 insertions(+) create mode 100644 grammars/tree-sitter-flow.cson create mode 100644 grammars/tree-sitter-typescript.cson diff --git a/grammars/tree-sitter-flow.cson b/grammars/tree-sitter-flow.cson new file mode 100644 index 0000000..6bc7c62 --- /dev/null +++ b/grammars/tree-sitter-flow.cson @@ -0,0 +1,116 @@ +id: 'flow-javascript' +name: 'Flow JavaScript' +type: 'tree-sitter' +parser: 'tree-sitter-typescript' + +fileTypes: [ + "js", + "flow.js", + "flow.jsx", +] + +firstLineMatch: '@flow' + +comments: + start: '// ' + +folds: + delimiters: [ + ['{', '}'] + ['(', ')'] + ['[', ']'] + ['jsx_opening_element', 'jsx_closing_element'] + ['<', '>'] + ] + + tokens: [ + ['comment', 2, 2] + ['template_string', 1, 1] + ] + +scopes: + 'program': 'source.js' + 'ERROR': 'syntax-error' + + 'property_identifier': 'variable.other.object.property' + + 'class > identifier': 'support.storage.type' + 'type_identifier': 'support.storage.type' + 'predefined_type': 'support.storage.type' + + 'function > identifier': 'entity.name.function' + 'call_expression > identifier': 'entity.name.function' + 'method_definition > property_identifier': 'entity.name.function' + 'call_expression > member_expression > property_identifier': 'entity.name.function' + + 'new_expression > call_expression > identifier': 'meta.class.instance.constructor' + + 'number': 'constant.numeric.decimal' + 'string': 'string.quoted.single' + 'regex': 'string.regexp' + 'template_string': 'string.quoted.template' + 'undefined': 'constant.language' + 'null': 'constant.language.null' + 'true': 'constant.language.boolean.true' + 'false': 'constant.language.boolean.false' + 'comment': 'comment.block' + + '"("': 'punctuation.definition.parameters.begin.bracket.round' + '")"': 'punctuation.definition.parameters.end.bracket.round' + '"{"': 'punctuation.definition.function.body.begin.bracket.curly' + '"}"': 'punctuation.definition.function.body.end.bracket.curly' + + '"var"': 'storage.modifier' + '"declare"': 'storage.modifier' + '"let"': 'storage.modifier' + '"const"': 'storage.modifier' + '"static"': 'storage.modifier' + '"public"': 'storage.modifier' + '"private"': 'storage.modifier' + 'readonly': 'storage.modifier' + '"class"': 'storage.type.class' + '"function"': 'storage.type.function' + '"type"': 'storage.type.type' + + '"+"': 'keyword.operator' + '"-"': 'keyword.operator' + '"*"': 'keyword.operator' + '"/"': 'keyword.operator' + '"in"': 'keyword.operator.in' + '"instanceof"': 'keyword.operator.instanceof' + '"of"': 'keyword.operator.of' + '"new"': 'keyword.operator.new' + '"typeof"': 'keyword.operator.typeof' + + '"get"': 'keyword.operator.setter' + '"set"': 'keyword.operator.setter' + + '"."': 'meta.delimiter.property.period' + '","': 'meta.delimiter.object.comma' + + '"if"': 'keyword.control' + '"do"': 'keyword.control' + '"else"': 'keyword.control' + '"while"': 'keyword.control' + '"for"': 'keyword.control' + '"return"': 'keyword.control' + '"break"': 'keyword.control' + '"continue"': 'keyword.control' + '"throw"': 'keyword.control' + '"try"': 'keyword.control' + '"catch"': 'keyword.control' + '"finally"': 'keyword.control' + '"switch"': 'keyword.control' + '"case"': 'keyword.control' + '"default"': 'keyword.control' + '"export"': 'keyword.control' + '"import"': 'keyword.control' + '"from"': 'keyword.control' + '"yield"': 'keyword.control' + '"async"': 'keyword.control' + '"await"': 'keyword.control' + + 'jsx_attribute': 'entity.other.attribute-name' + 'jsx_opening_element > identifier': 'entity.name.tag' + 'jsx_closing_element > identifier': 'entity.name.tag' + 'jsx_self_closing_element > identifier': 'entity.name.tag' diff --git a/grammars/tree-sitter-typescript.cson b/grammars/tree-sitter-typescript.cson new file mode 100644 index 0000000..3962f0e --- /dev/null +++ b/grammars/tree-sitter-typescript.cson @@ -0,0 +1,110 @@ +id: 'typescript' +name: 'TypeScript' +type: 'tree-sitter' +parser: 'tree-sitter-typescript' + +fileTypes: ["ts", "tsx", "js.flow"] + +comments: + start: '// ' + +folds: + delimiters: [ + ['{', '}'] + ['(', ')'] + ['[', ']'] + ['jsx_opening_element', 'jsx_closing_element'] + ['<', '>'] + ] + + tokens: [ + ['comment', 2, 2] + ['template_string', 1, 1] + ] + +scopes: + 'program': 'source.js' + 'ERROR': 'syntax-error' + + 'property_identifier': 'variable.other.object.property' + + 'class > identifier': 'support.storage.type' + 'type_identifier': 'support.storage.type' + 'predefined_type': 'support.storage.type' + + 'function > identifier': 'entity.name.function' + 'call_expression > identifier': 'entity.name.function' + 'method_definition > property_identifier': 'entity.name.function' + 'call_expression > member_expression > property_identifier': 'entity.name.function' + + 'new_expression > call_expression > identifier': 'meta.class.instance.constructor' + + 'number': 'constant.numeric.decimal' + 'string': 'string.quoted.single' + 'regex': 'string.regexp' + 'template_string': 'string.quoted.template' + 'undefined': 'constant.language' + 'null': 'constant.language.null' + 'true': 'constant.language.boolean.true' + 'false': 'constant.language.boolean.false' + 'comment': 'comment.block' + + '"("': 'punctuation.definition.parameters.begin.bracket.round' + '")"': 'punctuation.definition.parameters.end.bracket.round' + '"{"': 'punctuation.definition.function.body.begin.bracket.curly' + '"}"': 'punctuation.definition.function.body.end.bracket.curly' + + '"var"': 'storage.modifier' + '"declare"': 'storage.modifier' + '"let"': 'storage.modifier' + '"const"': 'storage.modifier' + '"static"': 'storage.modifier' + '"public"': 'storage.modifier' + '"private"': 'storage.modifier' + 'readonly': 'storage.modifier' + '"class"': 'storage.type.class' + '"function"': 'storage.type.function' + '"type"': 'storage.type.type' + + '"+"': 'keyword.operator' + '"-"': 'keyword.operator' + '"*"': 'keyword.operator' + '"/"': 'keyword.operator' + '"in"': 'keyword.operator.in' + '"instanceof"': 'keyword.operator.instanceof' + '"of"': 'keyword.operator.of' + '"new"': 'keyword.operator.new' + '"typeof"': 'keyword.operator.typeof' + + '"get"': 'keyword.operator.setter' + '"set"': 'keyword.operator.setter' + + '"."': 'meta.delimiter.property.period' + '","': 'meta.delimiter.object.comma' + + '"if"': 'keyword.control' + '"do"': 'keyword.control' + '"else"': 'keyword.control' + '"while"': 'keyword.control' + '"for"': 'keyword.control' + '"return"': 'keyword.control' + '"break"': 'keyword.control' + '"continue"': 'keyword.control' + '"throw"': 'keyword.control' + '"try"': 'keyword.control' + '"catch"': 'keyword.control' + '"finally"': 'keyword.control' + '"switch"': 'keyword.control' + '"case"': 'keyword.control' + '"default"': 'keyword.control' + '"export"': 'keyword.control' + '"import"': 'keyword.control' + '"from"': 'keyword.control' + '"yield"': 'keyword.control' + '"async"': 'keyword.control' + '"await"': 'keyword.control' + + 'jsx_attribute': 'entity.other.attribute-name' + 'jsx_opening_element > identifier': 'entity.name.tag' + 'jsx_closing_element > identifier': 'entity.name.tag' + 'jsx_self_closing_element > identifier': 'entity.name.tag' diff --git a/package.json b/package.json index e3cad80..423a438 100644 --- a/package.json +++ b/package.json @@ -14,5 +14,8 @@ "license": "MIT", "bugs": { "url": "https://github.com/atom/language-typescript/issues" + }, + "dependencies": { + "tree-sitter-typescript": "^0.4.2" } } From f3f6c73d5bb368b24a9316007ca1cd9dd30b11b8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 5 Dec 2017 14:12:21 -0800 Subject: [PATCH 02/11] Update fold config in tree-sitter grammars --- grammars/tree-sitter-flow.cson | 59 ++++++++++++++++++++-------- grammars/tree-sitter-typescript.cson | 53 ++++++++++++++++++------- 2 files changed, 80 insertions(+), 32 deletions(-) diff --git a/grammars/tree-sitter-flow.cson b/grammars/tree-sitter-flow.cson index 6bc7c62..7806214 100644 --- a/grammars/tree-sitter-flow.cson +++ b/grammars/tree-sitter-flow.cson @@ -4,9 +4,11 @@ type: 'tree-sitter' parser: 'tree-sitter-typescript' fileTypes: [ - "js", - "flow.js", - "flow.jsx", + 'js' + 'flow.js' + 'flow.jsx' + 'js.flow' + 'jsx.flow' ] firstLineMatch: '@flow' @@ -14,19 +16,42 @@ firstLineMatch: '@flow' comments: start: '// ' -folds: - delimiters: [ - ['{', '}'] - ['(', ')'] - ['[', ']'] - ['jsx_opening_element', 'jsx_closing_element'] - ['<', '>'] - ] - - tokens: [ - ['comment', 2, 2] - ['template_string', 1, 1] - ] +folds: [ + { + type: ['comment', 'template_string'] + } + { + type: 'jsx_element' + start: {index: 0} + end: {index: -1} + } + { + type: 'jsx_self_closing_element' + start: {index: 1} + end: {index: -2} + } + { + type: [ + 'object_type' + 'template_arguments' + 'template_parameters' + ] + start: {index: 0} + end: {index: -1} + } + { + start: {index: 0, type: '{'} + end: {index: -1, type: '}'} + } + { + start: {index: 0, type: '['} + end: {index: -1, type: ']'} + } + { + start: {index: 0, type: '('} + end: {index: -1, type: ')'} + } +] scopes: 'program': 'source.js' @@ -110,7 +135,7 @@ scopes: '"async"': 'keyword.control' '"await"': 'keyword.control' - 'jsx_attribute': 'entity.other.attribute-name' + 'jsx_attribute > property_identifier': 'entity.other.attribute-name' 'jsx_opening_element > identifier': 'entity.name.tag' 'jsx_closing_element > identifier': 'entity.name.tag' 'jsx_self_closing_element > identifier': 'entity.name.tag' diff --git a/grammars/tree-sitter-typescript.cson b/grammars/tree-sitter-typescript.cson index 3962f0e..33344df 100644 --- a/grammars/tree-sitter-typescript.cson +++ b/grammars/tree-sitter-typescript.cson @@ -3,24 +3,47 @@ name: 'TypeScript' type: 'tree-sitter' parser: 'tree-sitter-typescript' -fileTypes: ["ts", "tsx", "js.flow"] +fileTypes: ['ts', 'tsx'] comments: start: '// ' -folds: - delimiters: [ - ['{', '}'] - ['(', ')'] - ['[', ']'] - ['jsx_opening_element', 'jsx_closing_element'] - ['<', '>'] - ] - - tokens: [ - ['comment', 2, 2] - ['template_string', 1, 1] - ] +folds: [ + { + type: ['comment', 'template_string'] + } + { + type: 'jsx_element' + start: {index: 0} + end: {index: -1} + } + { + type: 'jsx_self_closing_element' + start: {index: 1} + end: {index: -2} + } + { + type: [ + 'object_type' + 'template_arguments' + 'template_parameters' + ] + start: {index: 0} + end: {index: -1} + } + { + start: {index: 0, type: '{'} + end: {index: -1, type: '}'} + } + { + start: {index: 0, type: '['} + end: {index: -1, type: ']'} + } + { + start: {index: 0, type: '('} + end: {index: -1, type: ')'} + } +] scopes: 'program': 'source.js' @@ -104,7 +127,7 @@ scopes: '"async"': 'keyword.control' '"await"': 'keyword.control' - 'jsx_attribute': 'entity.other.attribute-name' + 'jsx_attribute > property_identifier': 'entity.other.attribute-name' 'jsx_opening_element > identifier': 'entity.name.tag' 'jsx_closing_element > identifier': 'entity.name.tag' 'jsx_self_closing_element > identifier': 'entity.name.tag' From 9f57107d1126ced71486f43893c3f9a41c375517 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 5 Dec 2017 17:48:35 -0800 Subject: [PATCH 03/11] Use new contentRegExp field for flow --- grammars/tree-sitter-flow.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-flow.cson b/grammars/tree-sitter-flow.cson index 7806214..cf34b2d 100644 --- a/grammars/tree-sitter-flow.cson +++ b/grammars/tree-sitter-flow.cson @@ -11,7 +11,7 @@ fileTypes: [ 'jsx.flow' ] -firstLineMatch: '@flow' +contentRegExp: '(/\\*([^*]|\\*[^/])*|//.*)@flow' comments: start: '// ' From 25d65f0bd836f671e6fcca1f40a6a31bc7c9c6a1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 5 Dec 2017 17:48:43 -0800 Subject: [PATCH 04/11] Prepare 0.2.4-0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 423a438..a3809f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-typescript", - "version": "0.2.3", + "version": "0.2.4-0", "description": "TypeScript language support in Atom", "engines": { "atom": ">=1.19.1", From 0c7758b179ccf6baa78204d6d4972d2b1039e22d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 5 Dec 2017 17:57:02 -0800 Subject: [PATCH 05/11] Prepare 0.3.0-0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8135c7a..f5b0219 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-typescript", - "version": "0.2.4", + "version": "0.3.0-0", "description": "TypeScript language support in Atom", "engines": { "atom": ">=1.19.1", From bf62a8b7464fb193148a27c450181ec623b426ac Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 6 Dec 2017 11:15:58 -0800 Subject: [PATCH 06/11] Fix template string folding --- grammars/tree-sitter-flow.cson | 4 ++-- grammars/tree-sitter-typescript.cson | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grammars/tree-sitter-flow.cson b/grammars/tree-sitter-flow.cson index cf34b2d..1a601ae 100644 --- a/grammars/tree-sitter-flow.cson +++ b/grammars/tree-sitter-flow.cson @@ -18,10 +18,10 @@ comments: folds: [ { - type: ['comment', 'template_string'] + type: 'comment' } { - type: 'jsx_element' + type: ['jsx_element', 'template_string'] start: {index: 0} end: {index: -1} } diff --git a/grammars/tree-sitter-typescript.cson b/grammars/tree-sitter-typescript.cson index 33344df..1504f8f 100644 --- a/grammars/tree-sitter-typescript.cson +++ b/grammars/tree-sitter-typescript.cson @@ -10,10 +10,10 @@ comments: folds: [ { - type: ['comment', 'template_string'] + type: 'comment' } { - type: 'jsx_element' + type: ['jsx_element', 'template_string'] start: {index: 0} end: {index: -1} } From 743fe1e5df00637cfbe741a9f44d70cac9f2f4fa Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 6 Dec 2017 14:15:36 -0800 Subject: [PATCH 07/11] Prepare 0.3.0-1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5b0219..d1475f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-typescript", - "version": "0.3.0-0", + "version": "0.3.0-1", "description": "TypeScript language support in Atom", "engines": { "atom": ">=1.19.1", From 37e0ab0aad68f41d272770615185a1a5b9efe6dc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 15 Dec 2017 16:42:08 -0800 Subject: [PATCH 08/11] Add legacy scope name property --- grammars/tree-sitter-typescript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-typescript.cson b/grammars/tree-sitter-typescript.cson index 1504f8f..87cb87b 100644 --- a/grammars/tree-sitter-typescript.cson +++ b/grammars/tree-sitter-typescript.cson @@ -2,6 +2,7 @@ id: 'typescript' name: 'TypeScript' type: 'tree-sitter' parser: 'tree-sitter-typescript' +legacyScopeName: 'source.ts' fileTypes: ['ts', 'tsx'] From 9c88296ee278437d4f7621984081404c7db7fad6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 15 Dec 2017 16:42:13 -0800 Subject: [PATCH 09/11] Prepare 0.3.0-2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d1475f1..725d8e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-typescript", - "version": "0.3.0-1", + "version": "0.3.0-2", "description": "TypeScript language support in Atom", "engines": { "atom": ">=1.19.1", From d42babfaae46ddbd4b4be92793e9aa48dc2abc74 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 26 Dec 2017 13:46:36 -0800 Subject: [PATCH 10/11] :arrow_up: tree-sitter-typescript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 725d8e9..8317b64 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,6 @@ "url": "https://github.com/atom/language-typescript/issues" }, "dependencies": { - "tree-sitter-typescript": "^0.4.2" + "tree-sitter-typescript": "^0.5.0" } } From b0597f596948951b03afec2109c640c9ba986142 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 26 Dec 2017 13:46:45 -0800 Subject: [PATCH 11/11] Prepare 0.3.0-3 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8317b64..a6dfa31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-typescript", - "version": "0.3.0-2", + "version": "0.3.0-3", "description": "TypeScript language support in Atom", "engines": { "atom": ">=1.19.1",