From 36bcd70ff5066f0d268f6405e31c3340849dc001 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:26:19 -0700 Subject: [PATCH 01/46] Adjust `meta.block` scopes so that they're active only when inside curly braces --- .../grammars/ts/highlights.scm | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/language-javascript/grammars/ts/highlights.scm b/packages/language-javascript/grammars/ts/highlights.scm index 8ce5bf7170..39ac3579bb 100644 --- a/packages/language-javascript/grammars/ts/highlights.scm +++ b/packages/language-javascript/grammars/ts/highlights.scm @@ -543,10 +543,18 @@ (#match? @punctuation.definition.comment.js "^\/\/") (#set! adjust.startAndEndAroundFirstMatchOf "^\/\/")) +((comment) @comment.block.documentation.js + (#match? @comment.block.documentation.js "^/\\*\\*") + (#set! capture.final true) + (#set! highlight.invalidateOnChange true)) + + ; Block comments. `/* */` ((comment) @comment.block.js (#match? @comment.block.js "^/\\*") - (#match? @comment.block.js "\\*/$")) + (#match? @comment.block.js "\\*/$") + (#set! highlight.invalidateOnChange true)) + ((comment) @punctuation.definition.comment.begin.js (#match? @punctuation.definition.comment.begin.js "^/\\*") @@ -888,29 +896,43 @@ ; The interiors of functions (useful for snippets and commands). (method_definition body: (statement_block) @meta.block.function.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition) (#set! capture.final true)) (function_declaration body: (statement_block) @meta.block.function.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition) (#set! capture.final true)) (generator_function_declaration body: (statement_block) @meta.block.function.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition) (#set! capture.final true)) (function body: (statement_block) @meta.block.function.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition) (#set! capture.final true)) (generator_function body: (statement_block) @meta.block.function.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition) (#set! capture.final true)) ; The interior of a class body (useful for snippets and commands). -(class_body) @meta.block.class.js +((class_body) @meta.block.class.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition)) ; All other sorts of blocks. -(statement_block) @meta.block.js +((statement_block) @meta.block.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition)) ; The inside of a parameter definition list. ((formal_parameters) @meta.parameters.js From 54c4a3a4fb8e1e9044dfbf6ebfc2a926453d06d7 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:27:15 -0700 Subject: [PATCH 02/46] Fix JavaScript folds: * When a list of parameters is formatted with one on each line, you should be able to fold up the whole thing. * Block comment folds should end just before the closing delimiter, no matter what their indentation level. --- .../language-javascript/grammars/ts/folds.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/language-javascript/grammars/ts/folds.scm b/packages/language-javascript/grammars/ts/folds.scm index d9b0e5142a..d907958ada 100644 --- a/packages/language-javascript/grammars/ts/folds.scm +++ b/packages/language-javascript/grammars/ts/folds.scm @@ -3,15 +3,23 @@ (switch_body) (class_body) (object) - (formal_parameters) (template_string) (named_imports) ] @fold -((arguments) @fold +; When we've got +; +; function foo( +; bar, +; baz, +; thud +; ) +; +; we want to be able to fold up the group of function parameters while +; preserving the ability to collapse the function body. +([(arguments) (formal_parameters)] @fold (#set! fold.adjustToEndOfPreviousRow true)) - ; When we've got ; ; if (foo) { @@ -32,7 +40,7 @@ ((comment) @fold (#set! fold.endAt endPosition) - (#set! fold.adjustEndColumn 0)) + (#set! fold.offsetEnd -2)) ; When you have… From b03b56d90512d1b6913353e73487f4276a579133 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:28:08 -0700 Subject: [PATCH 03/46] JavaScript tags.scm: associate methods with their class name --- .../language-javascript/grammars/ts/tags.scm | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/packages/language-javascript/grammars/ts/tags.scm b/packages/language-javascript/grammars/ts/tags.scm index b89f362be5..5063d183f9 100644 --- a/packages/language-javascript/grammars/ts/tags.scm +++ b/packages/language-javascript/grammars/ts/tags.scm @@ -2,8 +2,10 @@ (comment)* @doc . (method_definition - name: (property_identifier) @name) @definition.method - (#not-eq? @name "constructor") + name: (property_identifier) @name + (#set! symbol.contextNode "parent.parent.parent.firstNamedChild") + ) @definition.method + ; (#not-eq? @name "constructor") (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") (#select-adjacent! @doc @definition.method) ) @@ -22,19 +24,6 @@ name: (_) @name) @definition.class ) -; ( -; (comment)* @doc -; . -; [ -; (class -; name: (_) @name) -; (class_declaration -; name: (_) @name) -; ] @definition.class -; (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") -; (#select-adjacent! @doc @definition.class) -; ) - ( (comment)* @doc . @@ -87,19 +76,19 @@ key: (property_identifier) @name value: [(arrow_function) (function)]) @definition.function -; ( -; (call_expression -; function: (identifier) @name) @reference.call -; (#not-match? @name "^(require)$") -; ) -; -; (call_expression -; function: (member_expression -; property: (property_identifier) @name) -; arguments: (_) @reference.call) -; -; (new_expression -; constructor: (_) @name) @reference.class +( + (call_expression + function: (identifier) @name) @reference.call + (#not-match? @name "^(require)$") +) + +(call_expression + function: (member_expression + property: (property_identifier) @name) + arguments: (_)) @reference.call + +(new_expression + constructor: (_) @name) @reference.class (export_statement value: (assignment_expression left: (identifier) @name right: ([ (number) From d0b3b0829576c61b7a6645525aedc10604b10d13 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:28:52 -0700 Subject: [PATCH 04/46] JavaScript: Stop handling injections for TypeScript and TSX Instead, move that code to `language-typescript/lib/main`. --- packages/language-javascript/lib/main.js | 57 +++++++++++------------- packages/language-typescript/lib/main.js | 36 ++++++++++++++- 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/packages/language-javascript/lib/main.js b/packages/language-javascript/lib/main.js index a6488be3a1..9df866a6e2 100644 --- a/packages/language-javascript/lib/main.js +++ b/packages/language-javascript/lib/main.js @@ -1,4 +1,4 @@ -exports.activate = function() { +exports.activate = function () { if (!atom.grammars.addInjectionPoint) return; atom.grammars.addInjectionPoint('source.js', { @@ -70,41 +70,38 @@ exports.activate = function() { const TODO_PATTERN = /\b(TODO|FIXME|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG|QUESTION|COMBAK|TEMP|DEBUG|OPTIMIZE|WARNING)\b/; const HYPERLINK_PATTERN = /\bhttps?:/ - for (const scopeName of ['source.js', 'source.ts', 'source.ts.tsx']) { - atom.grammars.addInjectionPoint(scopeName, { - type: 'comment', - language(comment) { - if (comment.text.startsWith('/**')) return 'jsdoc'; - }, - content(comment) { - return comment; - }, - languageScope: null, - coverShallowerScopes: true - }); + atom.grammars.addInjectionPoint('source.js', { + type: 'comment', + language(comment) { + if (comment.text.startsWith('/**')) return 'jsdoc'; + }, + content(comment) { + return comment; + }, + languageScope: null, + coverShallowerScopes: true + }); - // Experiment: better to have one layer with lots of nodes, or lots of - // layers each managing one node? - atom.grammars.addInjectionPoint(scopeName, { - type: 'comment', + // Experiment: better to have one layer with lots of nodes, or lots of + // layers each managing one node? + atom.grammars.addInjectionPoint('source.js', { + type: 'comment', + language: (node) => { + return TODO_PATTERN.test(node.text) ? 'todo' : undefined; + }, + content: (node) => node, + languageScope: null + }); + + for (let type of ['template_string', 'string_fragment', 'comment']) { + atom.grammars.addInjectionPoint('source.js', { + type, language: (node) => { - return TODO_PATTERN.test(node.text) ? 'todo' : undefined; + return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined; }, content: (node) => node, languageScope: null }); - - for (let type of ['template_string', 'string_fragment', 'comment']) { - atom.grammars.addInjectionPoint(scopeName, { - type, - language: (node) => { - return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined; - }, - content: (node) => node, - languageScope: null - }); - } - } }; diff --git a/packages/language-typescript/lib/main.js b/packages/language-typescript/lib/main.js index e226ed8ce1..dd7f400516 100644 --- a/packages/language-typescript/lib/main.js +++ b/packages/language-typescript/lib/main.js @@ -1,5 +1,17 @@ -exports.activate = function() { +exports.activate = function () { for (const scopeName of ['source.ts', 'source.tsx', 'source.flow']) { + atom.grammars.addInjectionPoint(scopeName, { + type: 'comment', + language(comment) { + if (comment.text.startsWith('/**')) return 'jsdoc'; + }, + content(comment) { + return comment; + }, + languageScope: null, + // coverShallowerScopes: true + }); + atom.grammars.addInjectionPoint(scopeName, { type: 'call_expression', @@ -53,9 +65,31 @@ exports.activate = function() { }, languageScope: null }); + + atom.grammars.addInjectionPoint(scopeName, { + type: 'comment', + language: (node) => { + return TODO_PATTERN.test(node.text) ? 'todo' : undefined; + }, + content: (node) => node, + languageScope: null + }); + + for (let type of ['template_string', 'string_fragment', 'comment']) { + atom.grammars.addInjectionPoint(scopeName, { + type, + language: (node) => { + return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined; + }, + content: (node) => node, + languageScope: null + }); + } } }; +const TODO_PATTERN = /\b(TODO|FIXME|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG|QUESTION|COMBAK|TEMP|DEBUG|OPTIMIZE|WARNING)\b/; +const HYPERLINK_PATTERN = /\bhttps?:/ const STYLED_REGEX = /\bstyled\b/i; function languageStringForTemplateTag(tag) { From 46f5e44fd166d6e4c66077aade9c66671e3e34c9 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:30:25 -0700 Subject: [PATCH 05/46] Fix bracket-matcher failing to find a match in Tree-sitter mode Occurred in a TSX file. --- packages/bracket-matcher/lib/bracket-matcher-view.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bracket-matcher/lib/bracket-matcher-view.js b/packages/bracket-matcher/lib/bracket-matcher-view.js index 4290d1968b..4d8cbb89aa 100644 --- a/packages/bracket-matcher/lib/bracket-matcher-view.js +++ b/packages/bracket-matcher/lib/bracket-matcher-view.js @@ -275,14 +275,14 @@ class BracketMatcherView { startTag = firstChild endTag = lastChild } + return true } - return true } }) return {startTag, endTag} } - findMatchingEndBracketWithRegexSearch (startBracketPosition, startBracket, endBracket) { + findMatchingEndBracketWithRegexSearch(startBracketPosition, startBracket, endBracket) { const scanRange = new Range( startBracketPosition.traverse(ONE_CHAR_FORWARD_TRAVERSAL), startBracketPosition.traverse(MAX_ROWS_TO_SCAN_FORWARD_TRAVERSAL) From cc31ed935baaab838b5d5c6844d68517f8d2457f Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:30:46 -0700 Subject: [PATCH 06/46] Reformat a `bracket-matcher` file --- .../lib/bracket-matcher-view.js | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/bracket-matcher/lib/bracket-matcher-view.js b/packages/bracket-matcher/lib/bracket-matcher-view.js index 4d8cbb89aa..76df8006e3 100644 --- a/packages/bracket-matcher/lib/bracket-matcher-view.js +++ b/packages/bracket-matcher/lib/bracket-matcher-view.js @@ -12,7 +12,7 @@ const MAX_ROWS_TO_SCAN_BACKWARD_TRAVERSAL = Object.freeze(Point(-MAX_ROWS_TO_SCA module.exports = class BracketMatcherView { - constructor (editor, editorElement, matchManager) { + constructor(editor, editorElement, matchManager) { this.destroy = this.destroy.bind(this) this.updateMatch = this.updateMatch.bind(this) this.editor = editor @@ -65,11 +65,11 @@ class BracketMatcherView { this.updateMatch() } - destroy () { + destroy() { this.subscriptions.dispose() } - updateMatch () { + updateMatch() { if (this.pairHighlighted) { this.editor.destroyMarker(this.startMarker.id) this.editor.destroyMarker(this.endMarker.id) @@ -113,13 +113,13 @@ class BracketMatcherView { this.tagHighlighted = highlightTag } - selectMatchingBrackets () { + selectMatchingBrackets() { if (!this.bracket1Range && !this.bracket2Range) return this.editor.setSelectedBufferRanges([this.bracket1Range, this.bracket2Range]) this.matchManager.changeBracketsMode = true } - removeMatchingBrackets () { + removeMatchingBrackets() { if (this.editor.hasMultipleCursors()) { this.editor.backspace() return @@ -159,7 +159,7 @@ class BracketMatcherView { }) } - findMatchingEndBracket (startBracketPosition, startBracket, endBracket) { + findMatchingEndBracket(startBracketPosition, startBracket, endBracket) { if (startBracket === endBracket) return if (this.hasSyntaxTree()) { @@ -171,7 +171,7 @@ class BracketMatcherView { } } - findMatchingStartBracket (endBracketPosition, startBracket, endBracket) { + findMatchingStartBracket(endBracketPosition, startBracket, endBracket) { if (startBracket === endBracket) return if (this.hasSyntaxTree()) { @@ -183,7 +183,7 @@ class BracketMatcherView { } } - findMatchingEndBracketWithSyntaxTree (bracketPosition, startBracket, endBracket) { + findMatchingEndBracketWithSyntaxTree(bracketPosition, startBracket, endBracket) { let result const bracketEndPosition = bracketPosition.traverse([0, startBracket.length]) this.editor.buffer.getLanguageMode().getSyntaxNodeContainingRange( @@ -202,7 +202,7 @@ class BracketMatcherView { return result } - findMatchingStartBracketWithSyntaxTree (bracketPosition, startBracket, endBracket) { + findMatchingStartBracketWithSyntaxTree(bracketPosition, startBracket, endBracket) { let result const bracketEndPosition = bracketPosition.traverse([0, startBracket.length]) this.editor.buffer.getLanguageMode().getSyntaxNodeContainingRange( @@ -221,7 +221,7 @@ class BracketMatcherView { return result } - findMatchingTagNameRangesWithSyntaxTree () { + findMatchingTagNameRangesWithSyntaxTree() { const position = this.editor.getCursorBufferPosition() const {startTag, endTag} = this.findContainingTagsWithSyntaxTree(position) if (startTag && (startTag.range.containsPoint(position) || endTag.range.containsPoint(position))) { @@ -244,7 +244,7 @@ class BracketMatcherView { } } - findMatchingTagsWithSyntaxTree () { + findMatchingTagsWithSyntaxTree() { const position = this.editor.getCursorBufferPosition() const {startTag, endTag} = this.findContainingTagsWithSyntaxTree(position) if (startTag) { @@ -254,7 +254,7 @@ class BracketMatcherView { } } - findContainingTagsWithSyntaxTree (position) { + findContainingTagsWithSyntaxTree(position) { let startTag, endTag if (position.column === this.editor.buffer.lineLengthForRow(position.row)) position.column--; this.editor.buffer.getLanguageMode().getSyntaxNodeAtPosition(position, node => { @@ -308,7 +308,7 @@ class BracketMatcherView { return endBracketPosition } - findMatchingStartBracketWithRegexSearch (endBracketPosition, startBracket, endBracket) { + findMatchingStartBracketWithRegexSearch(endBracketPosition, startBracket, endBracket) { const scanRange = new Range( endBracketPosition.traverse(MAX_ROWS_TO_SCAN_BACKWARD_TRAVERSAL), endBracketPosition @@ -334,7 +334,7 @@ class BracketMatcherView { return startBracketPosition } - findPrecedingStartBracket (cursorPosition) { + findPrecedingStartBracket(cursorPosition) { if (this.hasSyntaxTree()) { return this.findPrecedingStartBracketWithSyntaxTree(cursorPosition) } else { @@ -342,7 +342,7 @@ class BracketMatcherView { } } - findPrecedingStartBracketWithSyntaxTree (cursorPosition) { + findPrecedingStartBracketWithSyntaxTree(cursorPosition) { let result this.editor.buffer.getLanguageMode().getSyntaxNodeAtPosition(cursorPosition, node => { for (const child of node.children) { @@ -359,7 +359,7 @@ class BracketMatcherView { return result } - findPrecedingStartBracketWithRegexSearch (cursorPosition) { + findPrecedingStartBracketWithRegexSearch(cursorPosition) { const scanRange = new Range(Point.ZERO, cursorPosition) const startBracket = _.escapeRegExp(_.keys(this.matchManager.pairedCharacters).join('')) const endBracket = _.escapeRegExp(_.keys(this.matchManager.pairedCharactersInverse).join('')) @@ -384,7 +384,7 @@ class BracketMatcherView { return startPosition } - createMarker (bufferRange) { + createMarker(bufferRange) { const marker = this.editor.markBufferRange(bufferRange) this.editor.decorateMarker(marker, {type: 'highlight', class: 'bracket-matcher', deprecatedRegionClass: 'bracket-matcher'}) if (atom.config.get('bracket-matcher.highlightMatchingLineNumber', {scope: this.editor.getRootScopeDescriptor()}) && this.gutter) { @@ -393,7 +393,7 @@ class BracketMatcherView { return marker } - findCurrentPair () { + findCurrentPair() { const currentPosition = this.editor.getCursorBufferPosition() const previousPosition = currentPosition.traverse(ONE_CHAR_BACKWARD_TRAVERSAL) const nextPosition = currentPosition.traverse(ONE_CHAR_FORWARD_TRAVERSAL) @@ -422,7 +422,7 @@ class BracketMatcherView { return {position, matchPosition, bracket: currentBracket} } - goToMatchingBracket () { + goToMatchingBracket() { if (!this.pairHighlighted) return this.gotoPrecedingStartBracket() const position = this.editor.getCursorBufferPosition() @@ -468,7 +468,7 @@ class BracketMatcherView { } } - gotoPrecedingStartBracket () { + gotoPrecedingStartBracket() { if (this.pairHighlighted) return const matchPosition = this.findPrecedingStartBracket(this.editor.getCursorBufferPosition()) @@ -522,7 +522,7 @@ class BracketMatcherView { }) } - selectInsideBrackets () { + selectInsideBrackets() { let endPosition, endRange, startPosition, startRange if (this.pairHighlighted) { startRange = this.startMarker.getBufferRange() @@ -550,7 +550,7 @@ class BracketMatcherView { // Insert at the current cursor position a closing tag if there exists an // open tag that is not closed afterwards. - closeTag () { + closeTag() { const cursorPosition = this.editor.getCursorBufferPosition() const preFragment = this.editor.getTextInBufferRange([Point.ZERO, cursorPosition]) const postFragment = this.editor.getTextInBufferRange([cursorPosition, Point.INFINITY]) @@ -561,15 +561,15 @@ class BracketMatcherView { } } - isCursorOnCommentOrString () { + isCursorOnCommentOrString() { return this.isScopeCommentedOrString(this.editor.getLastCursor().getScopeDescriptor().getScopesArray()) } - isRangeCommentedOrString (range) { + isRangeCommentedOrString(range) { return this.isScopeCommentedOrString(this.editor.scopeDescriptorForBufferPosition(range.start).getScopesArray()) } - isScopeCommentedOrString (scopesArray) { + isScopeCommentedOrString(scopesArray) { for (let scope of scopesArray.reverse()) { scope = scope.split('.') if (scope.includes('embedded') && scope.includes('source')) return false @@ -579,7 +579,7 @@ class BracketMatcherView { return false } - hasSyntaxTree () { + hasSyntaxTree() { return this.editor.buffer.getLanguageMode().getSyntaxNodeAtPosition } } From cd392dfbd6d06d785ee8a5f84aa13f06179faca9 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:31:37 -0700 Subject: [PATCH 07/46] Tweak some C/C++ queries --- .../grammars/tree-sitter-c/highlights.scm | 14 +++++++++----- .../language-c/grammars/tree-sitter-c/locals.scm | 1 - .../language-c/grammars/tree-sitter-c/tags.scm | 3 ++- .../grammars/tree-sitter-cpp/locals.scm | 1 - .../language-c/grammars/tree-sitter-cpp/tags.scm | 16 +++++++++++++++- 5 files changed, 26 insertions(+), 9 deletions(-) delete mode 100644 packages/language-c/grammars/tree-sitter-c/locals.scm delete mode 100644 packages/language-c/grammars/tree-sitter-cpp/locals.scm diff --git a/packages/language-c/grammars/tree-sitter-c/highlights.scm b/packages/language-c/grammars/tree-sitter-c/highlights.scm index 402b1069d1..51778a17d9 100644 --- a/packages/language-c/grammars/tree-sitter-c/highlights.scm +++ b/packages/language-c/grammars/tree-sitter-c/highlights.scm @@ -70,6 +70,10 @@ ((primitive_type) @support.type.stdint.c (#match? @support.type.stdint.c "^(int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|int_least8_t|int_least16_t|int_least32_t|int_least64_t|uint_least8_t|uint_least16_t|uint_least32_t|uint_least64_t|int_fast8_t|int_fast16_t|int_fast32_t|int_fast64_t|uint_fast8_t|uint_fast16_t|uint_fast32_t|uint_fast64_t|intptr_t|uintptr_t|intmax_t|intmax_t|uintmax_t|uintmax_t)$")) +(enum_specifier + name: (type_identifier) @variable.other.declaration.type.c) +(type_definition + declarator: (_) @variable.other.declaration.type.c) ; CAVEAT: tree-sitter-c doesn't identify placeholders like `%c` in strings. ; Candidate for an injection grammar. @@ -111,19 +115,19 @@ declarator: (identifier) @variable.declaration.c) (field_declaration - (field_identifier) @variable.declaration.c) + (field_identifier) @entity.other.attribute-name.c) (field_declaration (pointer_declarator - (field_identifier) @variable.declaration.c)) + (field_identifier) @entity.other.attribute-name.c)) (field_declaration (array_declarator - (field_identifier) @variable.declaration.c)) + (field_identifier) @entity.other.attribute-name.c)) (init_declarator (pointer_declarator - (identifier) @variable.declaration.c)) + (identifier) @entity.other.attribute-name.c)) (assignment_expression left: (identifier) @variable.other.assignment.c) @@ -158,7 +162,7 @@ ; The "size" in `finfo->size`. (field_expression "->" - field: (field_identifier) @variable.other.member.c) + field: (field_identifier) @support.other.property.c) ; FUNCTIONS diff --git a/packages/language-c/grammars/tree-sitter-c/locals.scm b/packages/language-c/grammars/tree-sitter-c/locals.scm deleted file mode 100644 index 092bc2b041..0000000000 --- a/packages/language-c/grammars/tree-sitter-c/locals.scm +++ /dev/null @@ -1 +0,0 @@ -; diff --git a/packages/language-c/grammars/tree-sitter-c/tags.scm b/packages/language-c/grammars/tree-sitter-c/tags.scm index 3ef41679ad..491007448d 100644 --- a/packages/language-c/grammars/tree-sitter-c/tags.scm +++ b/packages/language-c/grammars/tree-sitter-c/tags.scm @@ -1,2 +1,3 @@ -((function_declarator (identifier) @name)) +(function_declarator + (identifier) @name) @definition.function diff --git a/packages/language-c/grammars/tree-sitter-cpp/locals.scm b/packages/language-c/grammars/tree-sitter-cpp/locals.scm deleted file mode 100644 index 092bc2b041..0000000000 --- a/packages/language-c/grammars/tree-sitter-cpp/locals.scm +++ /dev/null @@ -1 +0,0 @@ -; diff --git a/packages/language-c/grammars/tree-sitter-cpp/tags.scm b/packages/language-c/grammars/tree-sitter-cpp/tags.scm index 3ef41679ad..c44ee78e4e 100644 --- a/packages/language-c/grammars/tree-sitter-cpp/tags.scm +++ b/packages/language-c/grammars/tree-sitter-cpp/tags.scm @@ -1,2 +1,16 @@ -((function_declarator (identifier) @name)) +(function_declarator + (identifier) @name) @definition.function + +(function_declarator + declarator: (qualified_identifier) @name) @definition.function + +(class_specifier + name: (type_identifier) @name) @definition.class + +(class_specifier + body: (field_declaration_list + (function_definition + declarator: (function_declarator + declarator: (field_identifier) @name)) @definition.method) + (#set! symbol.contextNode "parent.parent.parent.parent.firstNamedChild")) From 99d230e7c6267c074547e4b5781905358360562f Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:32:07 -0700 Subject: [PATCH 08/46] Add some recognized values to the CSS `highlights.scm` --- .../language-css/grammars/tree-sitter/queries/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/language-css/grammars/tree-sitter/queries/highlights.scm b/packages/language-css/grammars/tree-sitter/queries/highlights.scm index 4301691ed0..4c4cc597d8 100644 --- a/packages/language-css/grammars/tree-sitter/queries/highlights.scm +++ b/packages/language-css/grammars/tree-sitter/queries/highlights.scm @@ -156,7 +156,7 @@ ; ------------------------ ((plain_value) @support.constant.property-value.css - (#match? @support.constant.property-value.css "^(above|absolute|active|add|additive|after-edge|alias|all|all-petite-caps|all-scroll|all-small-caps|alpha|alphabetic|alternate|alternate-reverse|always|antialiased|auto|auto-pos|available|avoid|avoid-column|avoid-page|avoid-region|backwards|balance|baseline|before-edge|below|bevel|bidi-override|blink|block|block-axis|block-start|block-end|bold|bolder|border|border-box|both|bottom|bottom-outside|break-all|break-word|bullets|butt|capitalize|caption|cell|center|central|char|circle|clip|clone|close-quote|closest-corner|closest-side|col-resize|collapse|color|color-burn|color-dodge|column|column-reverse|common-ligatures|compact|condensed|contain|content|content-box|contents|context-menu|contextual|copy|cover|crisp-edges|crispEdges|crosshair|cyclic|dark|darken|dashed|decimal|default|dense|diagonal-fractions|difference|digits|disabled|disc|discretionary-ligatures|distribute|distribute-all-lines|distribute-letter|distribute-space|dot|dotted|double|double-circle|downleft|downright|e-resize|each-line|ease|ease-in|ease-in-out|ease-out|economy|ellipse|ellipsis|embed|end|evenodd|ew-resize|exact|exclude|exclusion|expanded|extends|extra-condensed|extra-expanded|fallback|farthest-corner|farthest-side|fill|fill-available|fill-box|filled|fit-content|fixed|flat|flex|flex-end|flex-start|flip|flow-root|forwards|freeze|from-image|full-width|geometricPrecision|georgian|grab|grabbing|grayscale|grid|groove|hand|hanging|hard-light|help|hidden|hide|historical-forms|historical-ligatures|horizontal|horizontal-tb|hue|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|infinite|inherit|initial|inline|inline-axis|inline-block|inline-end|inline-flex|inline-grid|inline-list-item|inline-start|inline-table|inset|inside|inter-character|inter-ideograph|inter-word|intersect|invert|isolate|isolate-override|italic|jis04|jis78|jis83|jis90|justify|justify-all|kannada|keep-all|landscape|large|larger|left|light|lighten|lighter|line|line-edge|line-through|linear|linearRGB|lining-nums|list-item|local|loose|lowercase|lr|lr-tb|ltr|luminance|luminosity|main-size|mandatory|manipulation|manual|margin-box|match-parent|match-source|mathematical|max-content|medium|menu|message-box|middle|min-content|miter|mixed|move|multiply|n-resize|narrower|ne-resize|nearest-neighbor|nesw-resize|newspaper|no-change|no-clip|no-close-quote|no-common-ligatures|no-contextual|no-discretionary-ligatures|no-drop|no-historical-ligatures|no-open-quote|no-repeat|none|nonzero|normal|not-allowed|nowrap|ns-resize|numbers|numeric|nw-resize|nwse-resize|oblique|oldstyle-nums|open|open-quote|optimizeLegibility|optimizeQuality|optimizeSpeed|optional|ordinal|outset|outside|over|overlay|overline|padding|padding-box|page|painted|pan-down|pan-left|pan-right|pan-up|pan-x|pan-y|paused|petite-caps|pixelated|plaintext|pointer|portrait|pre|pre-line|pre-wrap|preserve-3d|progress|progressive|proportional-nums|proportional-width|proximity|radial|recto|region|relative|remove|repeat|repeat-[xy]|reset-size|reverse|revert|ridge|right|rl|rl-tb|round|row|row-resize|row-reverse|row-severse|rtl|ruby|ruby-base|ruby-base-container|ruby-text|ruby-text-container|run-in|running|s-resize|saturation|scale-down|screen|scroll|scroll-position|se-resize|semi-condensed|semi-expanded|separate|sesame|show|sideways|sideways-left|sideways-lr|sideways-right|sideways-rl|simplified|slashed-zero|slice|small|small-caps|small-caption|smaller|smooth|soft-light|solid|space|space-around|space-between|space-evenly|spell-out|square|sRGB|stacked-fractions|start|static|status-bar|swap|step-end|step-start|sticky|stretch|strict|stroke|stroke-box|style|sub|subgrid|subpixel-antialiased|subtract|super|sw-resize|symbolic|table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row|table-row-group|tabular-nums|tb|tb-rl|text|text-after-edge|text-before-edge|text-bottom|text-top|thick|thin|titling-caps|top|top-outside|touch|traditional|transparent|triangle|ultra-condensed|ultra-expanded|under|underline|unicase|unset|upleft|uppercase|upright|use-glyph-orientation|use-script|verso|vertical|vertical-ideographic|vertical-lr|vertical-rl|vertical-text|view-box|visible|visibleFill|visiblePainted|visibleStroke|w-resize|wait|wavy|weight|whitespace|wider|words|wrap|wrap-reverse|x|x-large|x-small|xx-large|xx-small|y|zero|zoom-in|zoom-out)$")) + (#match? @support.constant.property-value.css "^(above|absolute|active|add|additive|after-edge|alias|all|all-petite-caps|all-scroll|all-small-caps|alpha|alphabetic|alternate|alternate-reverse|always|antialiased|auto|auto-pos|available|avoid|avoid-column|avoid-page|avoid-region|backwards|balance|baseline|before-edge|below|bevel|bidi-override|blink|block|block-axis|block-start|block-end|bold|bolder|border|border-box|both|bottom|bottom-outside|break-all|break-word|bullets|butt|capitalize|caption|cell|center|central|char|circle|clip|clone|close-quote|closest-corner|closest-side|col-resize|collapse|color|color-burn|color-dodge|column|column-reverse|common-ligatures|compact|condensed|contain|content|content-box|contents|context-menu|contextual|copy|cover|crisp-edges|crispEdges|crosshair|cyclic|dark|darken|dashed|decimal|default|dense|diagonal-fractions|difference|digits|disabled|disc|discretionary-ligatures|distribute|distribute-all-lines|distribute-letter|distribute-space|dot|dotted|double|double-circle|downleft|downright|e-resize|each-line|ease|ease-in|ease-in-out|ease-out|economy|ellipse|ellipsis|embed|end|evenodd|ew-resize|exact|exclude|exclusion|expanded|extends|extra-condensed|extra-expanded|fallback|farthest-corner|farthest-side|fill|fill-available|fill-box|filled|fit-content|fixed|flat|flex|flex-end|flex-start|flip|flow-root|forwards|freeze|from-image|full-width|geometricPrecision|georgian|grab|grabbing|grayscale|grid|groove|hand|hanging|hard-light|help|hidden|hide|historical-forms|historical-ligatures|horizontal|horizontal-tb|hue|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|infinite|inherit|initial|inline|inline-axis|inline-block|inline-end|inline-flex|inline-grid|inline-list-item|inline-size|inline-start|inline-table|inset|inside|inter-character|inter-ideograph|inter-word|intersect|invert|isolate|isolate-override|italic|jis04|jis78|jis83|jis90|justify|justify-all|kannada|keep-all|landscape|large|larger|layout|left|light|lighten|lighter|line|line-edge|line-through|linear|linearRGB|lining-nums|list-item|local|loose|lowercase|lr|lr-tb|ltr|luminance|luminosity|main-size|mandatory|manipulation|manual|margin-box|match-parent|match-source|mathematical|max-content|medium|menu|message-box|middle|min-content|miter|mixed|move|multiply|n-resize|narrower|ne-resize|nearest-neighbor|nesw-resize|newspaper|no-change|no-clip|no-close-quote|no-common-ligatures|no-contextual|no-discretionary-ligatures|no-drop|no-historical-ligatures|no-open-quote|no-repeat|none|nonzero|normal|not-allowed|nowrap|ns-resize|numbers|numeric|nw-resize|nwse-resize|oblique|oldstyle-nums|open|open-quote|optimizeLegibility|optimizeQuality|optimizeSpeed|optional|ordinal|outset|outside|over|overlay|overline|padding|padding-box|page|paint|painted|pan-down|pan-left|pan-right|pan-up|pan-x|pan-y|paused|petite-caps|pixelated|plaintext|pointer|portrait|pre|pre-line|pre-wrap|preserve-3d|progress|progressive|proportional-nums|proportional-width|proximity|radial|recto|region|relative|remove|repeat|repeat-[xy]|reset-size|reverse|revert|ridge|right|rl|rl-tb|round|row|row-resize|row-reverse|row-severse|rtl|ruby|ruby-base|ruby-base-container|ruby-text|ruby-text-container|run-in|running|s-resize|saturation|scale-down|screen|scroll|scroll-position|se-resize|semi-condensed|semi-expanded|separate|sesame|show|sideways|sideways-left|sideways-lr|sideways-right|sideways-rl|simplified|size|slashed-zero|slice|small|small-caps|small-caption|smaller|smooth|soft-light|solid|space|space-around|space-between|space-evenly|spell-out|square|sRGB|stacked-fractions|start|static|status-bar|swap|step-end|step-start|sticky|stretch|strict|stroke|stroke-box|style|sub|subgrid|subpixel-antialiased|subtract|super|sw-resize|symbolic|table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row|table-row-group|tabular-nums|tb|tb-rl|text|text-after-edge|text-before-edge|text-bottom|text-top|thick|thin|titling-caps|top|top-outside|touch|traditional|transparent|triangle|ultra-condensed|ultra-expanded|under|underline|unicase|unset|upleft|uppercase|upright|use-glyph-orientation|use-script|verso|vertical|vertical-ideographic|vertical-lr|vertical-rl|vertical-text|view-box|visible|visibleFill|visiblePainted|visibleStroke|w-resize|wait|wavy|weight|whitespace|wider|words|wrap|wrap-reverse|x|x-large|x-small|xx-large|xx-small|y|zero|zoom-in|zoom-out)$")) ; All property values that have special meaning in `font-family`. ; TODO: Restrict these to be meaningful only when the property name is font-related? From cb4679f9d88ed7f5cb6459b2645b89c29962d4fc Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:33:46 -0700 Subject: [PATCH 09/46] Tweak JSX indentation hinting --- .../language-javascript/grammars/ts/indents.scm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/language-javascript/grammars/ts/indents.scm b/packages/language-javascript/grammars/ts/indents.scm index ce46a1393d..6aab803c11 100644 --- a/packages/language-javascript/grammars/ts/indents.scm +++ b/packages/language-javascript/grammars/ts/indents.scm @@ -94,23 +94,25 @@ ; ============================= ; TODO: We might want to make this configurable behavior with the -; `Config` scope test. +; `config` scope test. ; Any of these at the end of a line indicate the next line should be indented… (["||" "&&" "?"] @indent (#is? test.lastTextOnRow true)) -; …and the line after that should be dedented. +; …and the line after that should be dedented… (binary_expression ["||" "&&"] right: (_) @dedent.next (#is-not? test.startsOnSameRowAs parent.startPosition)) +; …unless it's a ternary, in which case the dedent should wait until the +; alternative clause. +; ; let foo = this.longTernaryCondition() ? ; consequenceWhichIsItselfRatherLong : ; alternativeThatIsNotBrief; ; -; …followed by a dedent. (ternary_expression alternative: (_) @dedent.next (#is-not? test.startsOnSameRowAs parent.startPosition)) @@ -153,5 +155,8 @@ ; JSX ; === -(jsx_opening_element ">") @indent -(jsx_closing_element ">") @dedent + +(jsx_opening_element ["<" ">"] @indent) +(jsx_opening_element [">"] @dedent) + +(jsx_closing_element ">" @dedent) From 7de9a82a42cad34237a9ad08d6974657a09b1bfe Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:34:01 -0700 Subject: [PATCH 10/46] Scope inline tags in JSDoc --- packages/language-javascript/grammars/ts/jsdoc/highlights.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/language-javascript/grammars/ts/jsdoc/highlights.scm b/packages/language-javascript/grammars/ts/jsdoc/highlights.scm index 549d7c3843..b9231f22bf 100644 --- a/packages/language-javascript/grammars/ts/jsdoc/highlights.scm +++ b/packages/language-javascript/grammars/ts/jsdoc/highlights.scm @@ -19,6 +19,7 @@ ((document) @punctuation.definition.end.comment.js.jsdoc (#set! adjust.startAndEndAroundFirstMatchOf "(?:\\*)?\\*/$")) +((inline_tag) @meta.inline-tag.js.jsdoc) (tag_name) @storage.type.class.jsdoc From 5c8f6abd941ed2cc9991ada6a4f28d9e0a4f4968 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:34:27 -0700 Subject: [PATCH 11/46] Tag properties as such in JSON's `tags.scm` --- packages/language-json/grammars/tree-sitter/queries/tags.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/language-json/grammars/tree-sitter/queries/tags.scm b/packages/language-json/grammars/tree-sitter/queries/tags.scm index 3c7d1defec..3e04140c39 100644 --- a/packages/language-json/grammars/tree-sitter/queries/tags.scm +++ b/packages/language-json/grammars/tree-sitter/queries/tags.scm @@ -4,6 +4,7 @@ ; Nested keys try to prepend the symbol name of their parent's key. (pair key: (string (string_content) @name (#is-not? test.descendantOfType "array") + (#set! symbol.tag "property") (#set! symbol.prependSymbolForNode parent.parent.parent.previousNamedSibling.firstNamedChild) (#set! symbol.contextNode parent.parent.parent.previousNamedSibling.firstNamedChild) (#set! symbol.joiner "."))) From 37a81ccb8200dc50bd43a7d807b20efe4c29dffa Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:36:44 -0700 Subject: [PATCH 12/46] Make the `fun` snippet work in more contexts `fun` expands to a simple function definition in JavaScript, but there are certain contexts where that syntax is invalid, making the snippet much less useful. Now that we're scoping the insides of class bodies and object literals, though, we can define more specific snippets for those contexts that use the correct syntax. The class-instance-method snippet and the inside-an-object-literal snippet are identical, except that the latter has a trailing comma. --- .../snippets/language-javascript.cson | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/language-javascript/snippets/language-javascript.cson b/packages/language-javascript/snippets/language-javascript.cson index cef3df6901..47ffd586ba 100644 --- a/packages/language-javascript/snippets/language-javascript.cson +++ b/packages/language-javascript/snippets/language-javascript.cson @@ -128,3 +128,18 @@ 'return': 'prefix': 'ret' 'body': 'return $1;$0' + +'.source.js .meta.block.function.js': + 'Function': + 'prefix': 'fun' + 'body': 'function ${1:functionName}($2) {\n\t$0\n}' + +'.source.js .meta.block.class.js': + 'Function': + 'prefix': 'fun' + 'body': '${1:functionName}($2) {\n\t$0\n}' + +'.source.js .meta.object.js': + 'Function': + 'prefix': 'fun' + 'body': '${1:functionName}($2) {\n\t$0\n},' From 2d802a745fe48d5db6f14e93fc23f89836db2fbe Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:37:38 -0700 Subject: [PATCH 13/46] Add TODO and Hyperlink injections to the shellscript grammar --- packages/language-shellscript/lib/main.js | 25 ++++++++++++++++++++++ packages/language-shellscript/package.json | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 packages/language-shellscript/lib/main.js diff --git a/packages/language-shellscript/lib/main.js b/packages/language-shellscript/lib/main.js new file mode 100644 index 0000000000..e2eb7368a6 --- /dev/null +++ b/packages/language-shellscript/lib/main.js @@ -0,0 +1,25 @@ +exports.activate = () => { + + const TODO_PATTERN = /\b(TODO|FIXME|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG|QUESTION|COMBAK|TEMP|DEBUG|OPTIMIZE|WARNING)\b/; + const HYPERLINK_PATTERN = /\bhttps?:/ + + atom.grammars.addInjectionPoint('source.shell', { + type: 'comment', + language: (node) => { + return TODO_PATTERN.test(node.text) ? 'todo' : undefined; + }, + content: (node) => node, + languageScope: null + }); + + atom.grammars.addInjectionPoint('source.shell', { + type: 'comment', + language(node) { + return HYPERLINK_PATTERN.test(node.text) ? + 'hyperlink' : undefined; + }, + content: (node) => node, + languageScope: null + }); + +}; diff --git a/packages/language-shellscript/package.json b/packages/language-shellscript/package.json index 68a12c9005..47fa9bc272 100644 --- a/packages/language-shellscript/package.json +++ b/packages/language-shellscript/package.json @@ -1,13 +1,14 @@ { "name": "language-shellscript", "version": "0.28.2", + "main": "lib/main", "description": "ShellScript language support in Atom", "keywords": [ "tree-sitter" ], "engines": { "atom": "*", - "node": "*" + "node": ">=12" }, "repository": "https://github.com/pulsar-edit/pulsar", "license": "MIT", From 0adb5e6dc82e4eaccc16504092f7dc4862cd05cb Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:38:09 -0700 Subject: [PATCH 14/46] Fold multi-line parameters in TypeScript and TSX --- .../language-typescript/grammars/common/folds.scm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/language-typescript/grammars/common/folds.scm b/packages/language-typescript/grammars/common/folds.scm index cbe82351ff..ee15e26e44 100644 --- a/packages/language-typescript/grammars/common/folds.scm +++ b/packages/language-typescript/grammars/common/folds.scm @@ -2,15 +2,23 @@ (switch_body) (class_body) (object) - (formal_parameters) (template_string) (named_imports) ] @fold -((arguments) @fold +; When we've got +; +; function foo( +; bar, +; baz, +; thud +; ) +; +; we want to be able to fold up the group of function parameters while +; preserving the ability to collapse the function body. +([(arguments) (formal_parameters)] @fold (#set! fold.adjustToEndOfPreviousRow true)) - ; When we've got ; ; if (foo) { From eb5d1c2198d7efde75bda7669640909c132a2f1b Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:39:12 -0700 Subject: [PATCH 15/46] Fix folding of block comments in TypeScript/TSX --- packages/language-typescript/grammars/common/folds.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/language-typescript/grammars/common/folds.scm b/packages/language-typescript/grammars/common/folds.scm index ee15e26e44..97c5a6f0f6 100644 --- a/packages/language-typescript/grammars/common/folds.scm +++ b/packages/language-typescript/grammars/common/folds.scm @@ -39,4 +39,4 @@ ((comment) @fold (#set! fold.endAt endPosition) - (#set! fold.adjustEndColumn 0)) + (#set! fold.offsetEnd -2)) From 4402d9ada4d5e70f12a369e8d0086860378a1ce0 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:40:40 -0700 Subject: [PATCH 16/46] Add some TypeScript/TSX highlights There were some constructs that we neglected to highlight properly, like type predicates and rest parameters. --- .../grammars/common/highlights.scm | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/packages/language-typescript/grammars/common/highlights.scm b/packages/language-typescript/grammars/common/highlights.scm index e83dac3d15..385ccfff2a 100644 --- a/packages/language-typescript/grammars/common/highlights.scm +++ b/packages/language-typescript/grammars/common/highlights.scm @@ -9,6 +9,10 @@ (import_specifier (identifier) @variable.other.assignment.import._LANG_) +; The "foo" in `import * as foo from './bar'` +(namespace_import + (identifier) @variable.other.assignment.import.namespace._LANG_) + ; The "Foo" in `export { Foo }` (export_specifier name: (identifier) @variable.other.assignment.export._LANG_) @@ -37,8 +41,19 @@ (#match? @punctuation.definition.comment._LANG_ "^//") (#set! adjust.startAndEndAroundFirstMatchOf "^//")) +((comment) @comment.block.documentation._LANG_ + (#match? @comment.block.documentation._LANG_ "^/\\*\\*") + (#set! capture.final true) + (#set! highlight.invalidateOnChange true)) + +; Block comments. `/* */` ((comment) @comment.block._LANG_ - (#match? @comment.block._LANG_ "^/\\*")) + (#match? @comment.block._LANG_ "^/\\*") + (#match? @comment.block._LANG_ "\\*/$") + (#set! highlight.invalidateOnChange true)) + +; ((comment) @comment.block._LANG_ +; (#match? @comment.block._LANG_ "^/\\*")) ((comment) @punctuation.definition.comment.begin._LANG_ (#match? @punctuation.definition.comment.begin._LANG_ "^/\\*") @@ -65,7 +80,8 @@ ; ======= (class_declaration - name: (type_identifier) @entity.name.type.class._LANG_) + name: (type_identifier) @entity.name.type.class._LANG_ + (#set! capture.final true)) (extends_clause value: (_) @entity.other.inherited-class._LANG_) @@ -90,12 +106,27 @@ "set" @storage.setter._LANG_) +; NAMESPACES +; ========== + +(internal_module + name: (identifier) @entity.name.type.namespace._LANG_) + + +; DECLARATIONS +; ============ + +(function_signature + name: (identifier) @entity.name.function.signature._LANG_) + + ; INTERFACES ; ========== (interface_declaration name: (_) @entity.name.type.interface._LANG_) + ; TYPES ; ===== @@ -178,6 +209,8 @@ (property_signature (property_identifier) @entity.other.attribute-name._LANG_) + + ; FUNCTIONS ; ========= @@ -259,6 +292,10 @@ (required_parameter pattern: (identifier) @variable.parameter._LANG_) +(required_parameter + pattern: (rest_pattern + (identifier) @variable.parameter.rest._LANG_)) + (required_parameter pattern: (object_pattern (shorthand_property_identifier_pattern) @variable.parameter.destructuring._LANG_) @@ -269,6 +306,9 @@ (optional_parameter "?" @keyword.operator.type.optional._LANG_) +(type_predicate + name: (identifier) @variable.other.type._LANG_ + "is" @keyword.operator.type.is._LANG_) ["var" "const" "let"] @storage.type._TYPE_._LANG_ @@ -306,7 +346,16 @@ (pair_pattern ; TODO: This arguably isn't an object key. key: (_) @entity.other.attribute-name._LANG_ - value: (identifier) @variable.other.assignment.destructuring._LANG_)) + value: (identifier) @variable.other.assignment.destructuring._LANG_) + (#set! capture.final true)) + +; A complex object alias destructuring: +; The "bar" in `let { bar: { foo: troz } } = something` +(object_pattern + (pair_pattern + ; TODO: This arguably isn't an object key. + key: (_) @entity.other.attribute-name._LANG_) + (#set! capture.final true)) ; A variable object alias destructuring with default value: ; The "bar" and "foo" in `let { bar: foo = true } = something` From 18606447cfb6530de14bc8508dd2e9842c63832c Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:41:25 -0700 Subject: [PATCH 17/46] Harmonize the TypeScript/TSX `indents.scm` with that of JavaScript --- .../grammars/common/indents.scm | 123 +++++++++++++++++- .../grammars/tree-sitter-tsx/indents.scm | 6 +- 2 files changed, 120 insertions(+), 9 deletions(-) diff --git a/packages/language-typescript/grammars/common/indents.scm b/packages/language-typescript/grammars/common/indents.scm index a85c78b0ab..427f19f0c2 100644 --- a/packages/language-typescript/grammars/common/indents.scm +++ b/packages/language-typescript/grammars/common/indents.scm @@ -1,14 +1,124 @@ -; The closing brace of a switch statement's body should match the indentation of the line where the switch statement starts. +; STATEMENT BLOCKS +; ================ + +; More accurate indentation matching for all blocks delimited by braces. +(statement_block "}" @match + (#set! indent.matchIndentOf parent.firstChild.startPosition)) + + +; SWITCH STATEMENTS +; ================= + +; The closing brace of a switch statement's body should match the indentation +; of the line where the switch statement starts. (switch_statement body: (switch_body "}" @match (#is? test.last true)) - (#set! indent.matchIndentOf parent.parent.startPosition)) + (#set! indent.matchIndentOf parent.startPosition)) ; 'case' and 'default' need to be indented one level more than their containing -; `switch`. - (["case" "default"] @match - (#set! indent.matchIndentOf parent.parent.startPosition) - (#set! indent.offsetIndent 1)) +; `switch`. TODO: Might need to make this configurable. +(["case" "default"] @match + (#set! indent.matchIndentOf parent.parent.startPosition) + (#set! indent.offsetIndent 1)) + + +; ONE-LINE CONDITIONALS +; ===================== + +; An `if` statement without an opening brace should indent the next line… +(if_statement + condition: (parenthesized_expression ")" @indent + (#is? test.lastTextOnRow true))) +; (as should a braceless `else`…) +("else" @indent + (#is? test.lastTextOnRow true)) + +; …and keep that indent level if the user types a comment before the +; consequence… +(if_statement + consequence: (empty_statement) @match + (#is-not? test.startsOnSameRowAs parent.startPosition) + (#set! indent.matchIndentOf parent.startPosition) + (#set! indent.offsetIndent 1)) + +; …and keep that indent level after the user starts typing… +(if_statement + condition: (_) @indent + consequence: [ + (expression_statement) + (return_statement) + (continue_statement) + (break_statement) + (throw_statement) + (debugger_statement) + ] @match + ; When an opening curly brace is unpaired, it might get interpreted as part + ; of an `expression_statement`, for some reason. + (#not-match? @match "^\\s*{") + (#set! indent.matchIndentOf parent.startPosition) + (#set! indent.offsetIndent 1)) + +; …but dedent after exactly one statement. +(if_statement + condition: (_) @indent + consequence: [ + (expression_statement) + (return_statement) + (continue_statement) + (break_statement) + (throw_statement) + (debugger_statement) + ] @dedent.next + ; When an opening curly brace is unpaired, it might get interpreted as part + ; of an `expression_statement`, for some reason. + (#not-match? @dedent.next "^\\s*{")) + +(else_clause + [ + (expression_statement) + (return_statement) + (continue_statement) + (break_statement) + (throw_statement) + (debugger_statement) + ] @dedent.next + (#is-not? test.startsOnSameRowAs parent.startPosition)) + +; HANGING INDENT ON SPLIT LINES +; ============================= + +; TODO: We might want to make this configurable behavior with the +; `config` scope test. + +; Any of these at the end of a line indicate the next line should be indented… +(["||" "&&" "?"] @indent + (#is? test.lastTextOnRow true)) + +; …and the line after that should be dedented. +(binary_expression + ["||" "&&"] + right: (_) @dedent.next + (#is-not? test.startsOnSameRowAs parent.startPosition)) + +; …unless it's a ternary, in which case the dedent should wait until the +; alternative clause. +; +; let foo = this.longTernaryCondition() ? +; consequenceWhichIsItselfRatherLong : +; alternativeThatIsNotBrief; +; +(ternary_expression + alternative: (_) @dedent.next + (#is-not? test.startsOnSameRowAs parent.startPosition)) + + +; GENERAL +; ======= + +; Weed out `}`s that should not signal dedents. +(template_substitution "}" @_IGNORE_ (#set! capture.final true)) + [ "{" @@ -27,5 +137,4 @@ (type_arguments "<" @indent) (type_arguments ">" @dedent) - ["case" "default"] @indent diff --git a/packages/language-typescript/grammars/tree-sitter-tsx/indents.scm b/packages/language-typescript/grammars/tree-sitter-tsx/indents.scm index dee9c2f64e..bd25180c16 100644 --- a/packages/language-typescript/grammars/tree-sitter-tsx/indents.scm +++ b/packages/language-typescript/grammars/tree-sitter-tsx/indents.scm @@ -2,5 +2,7 @@ ; JSX ; === -(jsx_opening_element) @indent -(jsx_closing_element ">") @dedent +(jsx_opening_element ["<" ">"] @indent) +(jsx_opening_element [">"] @dedent) + +(jsx_closing_element ">" @dedent) From 220e70fc41cf6b15551e7d1f8ff5f9ed038ad2d1 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:42:54 -0700 Subject: [PATCH 18/46] Ensure `setQueryForTest` fires the `onDidChangeQueryFile` callback --- src/wasm-tree-sitter-grammar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wasm-tree-sitter-grammar.js b/src/wasm-tree-sitter-grammar.js index 3ebb0aa4bc..1b89ba3473 100644 --- a/src/wasm-tree-sitter-grammar.js +++ b/src/wasm-tree-sitter-grammar.js @@ -127,7 +127,7 @@ module.exports = class WASMTreeSitterGrammar { this.observeQueryFile(filePaths, key); } } - Promise.all(promises).then(() => resolve()); + return Promise.all(promises).then(() => resolve()); }).then(() => { this._queryFilesLoaded = true; this._loadQueryFilesPromise = null; @@ -254,7 +254,9 @@ module.exports = class WASMTreeSitterGrammar { await this.getLanguage(); this.queryCache.delete(queryType); this[queryType] = contents; - return await this.getQuery(queryType); + let query = await this.getQuery(queryType); + this.emitter.emit('did-change-query-file', { filePath: '', queryType }); + return query; } // Observe a particular query file on disk so that it can immediately be From d5fb9f50077d5d3437ad10994dc2ea78971701da Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:44:21 -0700 Subject: [PATCH 19/46] Fix bug when trying to determine indentation level of a misaligned line For example: if tab size is set to 2, we should interpret a line with 3 leading spaces as having been indented 1 level, not 1.5. --- src/wasm-tree-sitter-language-mode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wasm-tree-sitter-language-mode.js b/src/wasm-tree-sitter-language-mode.js index bfba2af777..d7ac1cc0de 100644 --- a/src/wasm-tree-sitter-language-mode.js +++ b/src/wasm-tree-sitter-language-mode.js @@ -1124,7 +1124,7 @@ class WASMTreeSitterLanguageMode { break; } } - return indentLength / tabLength; + return Math.floor(indentLength / tabLength); } // Get the suggested indentation level for an existing line in the buffer. From 2358e1e90d0b2e7a25e30cb31eff7b49b57ec540 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 09:46:11 -0700 Subject: [PATCH 20/46] Surface more information when a grammar fails to load Also, recover from a malformed `highlights.scm` on load by loading an empty query file instead. It'll be obvious that the real query file failed to load. --- src/wasm-tree-sitter-language-mode.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wasm-tree-sitter-language-mode.js b/src/wasm-tree-sitter-language-mode.js index d7ac1cc0de..1fa602c4be 100644 --- a/src/wasm-tree-sitter-language-mode.js +++ b/src/wasm-tree-sitter-language-mode.js @@ -2821,10 +2821,10 @@ class GrammarLoadError extends Error { constructor(grammar, queryType) { super(`Grammar ${grammar.scopeName} failed to load its ${queryType}. Please fix this error or contact the maintainer.`); this.name = 'GrammarLoadError'; + this.queryType = queryType; } } - // Manages all aspects of a given language's parsing duties over a given region // of the buffer. // @@ -2898,6 +2898,13 @@ class LanguageLayer { }).catch((err) => { if (err.name === 'GrammarLoadError') { console.warn(err.message); + if (err.queryType === 'highlightsQuery') { + // TODO: Warning? + grammar.highlightsQuery = grammar.setQueryForTest( + 'highlightsQuery', + `; (placeholder)` + ); + } } else { throw err; } From 0039432bb46f9c3f360780d706bd9532a17d40ac Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 11:38:13 -0700 Subject: [PATCH 21/46] Rework how we find comment delimiters Checking on the grammar first means that we get no opportunity to override the answer. It also fails to account for languages in which the correct comment delimiters vary based on context. Instead, we check settings _first_, then fall back to the grammar itself. --- src/wasm-tree-sitter-grammar.js | 46 +++++++++++++++++ src/wasm-tree-sitter-language-mode.js | 71 +++++++++++++++++---------- 2 files changed, 90 insertions(+), 27 deletions(-) diff --git a/src/wasm-tree-sitter-grammar.js b/src/wasm-tree-sitter-grammar.js index 1b89ba3473..c14588fff5 100644 --- a/src/wasm-tree-sitter-grammar.js +++ b/src/wasm-tree-sitter-grammar.js @@ -45,6 +45,8 @@ module.exports = class WASMTreeSitterGrammar { commentEndString: params.comments && params.comments.end }; + this.commentMetadata = params.comments; + this.shouldObserveQueryFiles = atom.inDevMode() && !atom.inSpecMode(); this.getLanguage(); @@ -69,6 +71,50 @@ module.exports = class WASMTreeSitterGrammar { return id; } + // Retrieve the comment delimiters for this grammar. + // + // Traditionally, grammars specified only the delimiters needed for the + // “Toggle Line Comments” command — either a line comment (if it existed) or + // a block comment. But other features might want to know _all_ of a + // language's possible comment delimiters, so we've devised new config values. + getCommentDelimiters() { + let meta = this.commentMetadata; + if (!meta) { return null; } + + let result = {}; + + // The new convention is to specify a `line` property and start/end + // properties. + let { line, block } = this.commentMetadata; + + // Failing that, we can deliver at least a partial result by inspecting the + // older convention. If `start` exists but not `end`, we know `start` must + // be a line comment delimiter. + if (!line && meta.start && !meta.end) { + line = meta.start; + } + // Likewise, if both `start` and `end` exist, we know they must be block + // comment delimiters. + if (!block && meta.start && meta.end) { + block = { start: meta.start, end: meta.end }; + } + + // Strip all whitespace from delimiters. Whatever is consuming them can + // decide if it wants whitespace. + if (line) { + line = line.strip(); + result.line = line; + } + + if (block) { + block.start = block.start?.strip(); + block.end = block.end?.strip(); + result.block = block; + } + + return result; + } + classNameForScopeId(id) { return this.classNamesById.get(id); } diff --git a/src/wasm-tree-sitter-language-mode.js b/src/wasm-tree-sitter-language-mode.js index 1fa602c4be..559274b4de 100644 --- a/src/wasm-tree-sitter-language-mode.js +++ b/src/wasm-tree-sitter-language-mode.js @@ -1056,32 +1056,24 @@ class WASMTreeSitterLanguageMode { Section - Comments */ - // TODO: I know that old tree-sitter moved toward placing this data on the - // grammar itself, but I would prefer to invert the order of these lookups. - // As a config setting it can be scoped and overridden, but as a grammar - // property it's just a fact of life that can't be worked around. - // - // TODO: Also, this should be revisited soon so that we can give the - // `snippets` package the ability to ask about all of a grammar's comment - // tokens — both line and block. + // Returns the correct comment delimiters for the given buffer position. This + // may be defined on the grammar itself, but it can also be defined as a + // scope-specific setting for scenarios where a language has different + // comment delimiters for different contexts. // + // TODO: Our understanding of the correct delimiters for a given buffer + // position is only as granular as the entire buffer row. This can bite us in + // edge cases like JSX. It's the right decision if the user toggles a comment + // with an empty selection, but if specific buffer text is selected, we + // should look up the right delmiters for that specific range. This will + // require a new branch in the “Editor: Toggle Line Comments” command. commentStringsForPosition(position) { - // First ask the grammar for its comment strings. const range = this.firstNonWhitespaceRange(position.row) || new Range(position, position); - const { grammar } = this.getSyntaxNodeAndGrammarContainingRange(range); - if (grammar) { - let { commentStrings } = grammar; - // Some languages don't have block comments, so only check for the start - // delimiter. - if (commentStrings && commentStrings.commentStartString) { - return commentStrings; - } - } - - // Fall back to a lookup through the config system. - const scope = this.scopeDescriptorForPosition(position); + // Ask the config system if it has a setting for this scope. This allows + // for overrides from the grammar default. + const scope = this.scopeDescriptorForPosition(range.start); const commentStartEntries = this.config.getAll( 'editor.commentStart', { scope }); const commentEndEntries = this.config.getAll( @@ -1091,10 +1083,25 @@ class WASMTreeSitterLanguageMode { const commentEndEntry = commentEndEntries.find(entry => ( entry.scopeSelector === commentStartEntry.scopeSelector )); - return { - commentStartString: commentStartEntry && commentStartEntry.value, - commentEndString: commentEndEntry && commentEndEntry.value - }; + + if (commentStartEntry) { + return { + commentStartString: commentStartEntry && commentStartEntry.value, + commentEndString: commentEndEntry && commentEndEntry.value + }; + } + + // Fall back to looking up this information on the grammar. + const { grammar } = this.getSyntaxNodeAndGrammarContainingRange(range); + + if (grammar) { + let { commentStrings } = grammar; + // Some languages don't have block comments, so only check for the start + // delimiter. + if (commentStrings && commentStrings.commentStartString) { + return commentStrings; + } + } } isRowCommented(row) { @@ -1642,6 +1649,11 @@ class WASMTreeSitterLanguageMode { } } + if (!indentTree) { + console.error(`No indent tree!`, controllingLayer.inspect()); + return undefined; + } + const indents = indentsQuery.captures( indentTree.rootNode, { row: row, column: 0 }, @@ -2928,12 +2940,17 @@ class LanguageLayer { if (depth === 0) { languageScope = this.grammar.scopeName; } else { + // Injections can control the base scope name of the grammar being + // injected. languageScope = injectionPoint.languageScope; - // Honor an explicit `null`, but fall back to the default scope name - // otherwise. + + // The `languageScope` parameter can be a function. if (typeof languageScope === 'function') { languageScope = languageScope(this.grammar); } + + // Honor an explicit `null`, but fall back to the default scope name + // otherwise. if (languageScope === undefined) { languageScope = this.grammar.scopeName; } From ff34f2daf2ca611f2380bc289772d5305686989b Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 11:39:00 -0700 Subject: [PATCH 22/46] Use the proper comment delimiters when commenting out a range of JSX --- .../language-javascript/grammars/ts/highlights.scm | 14 ++++++++++++++ .../settings/language-javascript.cson | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/language-javascript/grammars/ts/highlights.scm b/packages/language-javascript/grammars/ts/highlights.scm index 39ac3579bb..74f81c9cc5 100644 --- a/packages/language-javascript/grammars/ts/highlights.scm +++ b/packages/language-javascript/grammars/ts/highlights.scm @@ -945,6 +945,20 @@ (#set! adjust.endAt lastChild.startPosition)) +([ + (jsx_opening_element) + (jsx_closing_element) +] @meta.jsx.inside-tag.js +(#set! adjust.startAt firstChild.endPosition)) + +((jsx_self_closing_element) @meta.jsx.inside-tag.js +(#set! adjust.startAt firstChild.endPosition) +(#set! adjust.endAt lastChild.startPosition)) + +((jsx_element) @meta.block.jsx.js + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition)) + ; MISC ; ==== diff --git a/packages/language-javascript/settings/language-javascript.cson b/packages/language-javascript/settings/language-javascript.cson index 37198cb09a..48b832fb6e 100644 --- a/packages/language-javascript/settings/language-javascript.cson +++ b/packages/language-javascript/settings/language-javascript.cson @@ -11,3 +11,13 @@ 'decreaseIndentPattern': '(?x) ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])] ' + +'.source.js .meta.block.jsx.js': + 'editor': + 'commentStart': '{/*' + 'commentEnd': '*/}' + +'.source.js .meta.jsx.inside-tag.js': + 'editor': + 'commentStart': '{/*' + 'commentEnd': '*/}' From 10907fb40ffa00778db67a315b8dc70c5717dda9 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 11:50:29 -0700 Subject: [PATCH 23/46] Use correct comment delimiters within JSX when using a TSX grammar --- .../grammars/tree-sitter-tsx/highlights.scm | 18 ++++++++++++++++++ .../settings/TypeScriptReact.cson | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/language-typescript/grammars/tree-sitter-tsx/highlights.scm b/packages/language-typescript/grammars/tree-sitter-tsx/highlights.scm index e0f9956337..c8b90d23a2 100644 --- a/packages/language-typescript/grammars/tree-sitter-tsx/highlights.scm +++ b/packages/language-typescript/grammars/tree-sitter-tsx/highlights.scm @@ -38,3 +38,21 @@ (#set! adjust.startAt lastChild.previousSibling.startPosition) (#set! adjust.endAt lastChild.endPosition) (#set! capture.final true)) + + +; META +; ==== + +([ + (jsx_opening_element) + (jsx_closing_element) +] @meta.jsx.inside-tag.ts.tsx +(#set! adjust.startAt firstChild.endPosition)) + +((jsx_self_closing_element) @meta.jsx.inside-tag.ts.tsx +(#set! adjust.startAt firstChild.endPosition) +(#set! adjust.endAt lastChild.startPosition)) + +((jsx_element) @meta.block.jsx.ts.tsx + (#set! adjust.startAt firstChild.endPosition) + (#set! adjust.endAt lastChild.startPosition)) diff --git a/packages/language-typescript/settings/TypeScriptReact.cson b/packages/language-typescript/settings/TypeScriptReact.cson index 941998002a..4ffd626388 100644 --- a/packages/language-typescript/settings/TypeScriptReact.cson +++ b/packages/language-typescript/settings/TypeScriptReact.cson @@ -11,9 +11,9 @@ ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])] ' -'.meta.tag.tsx': +'.meta.tag.tsx, .meta.block.jsx.ts.tsx': 'editor': 'commentStart': '{/* ', 'commentEnd': ' */}', 'increaseIndentPattern': "{[^}\"']*$|\\[[^\\]\"']*$|\\([^)\"']*$|<[a-zA-Z][^/]*$|^\\s*>$", - 'decreaseIndentPattern': "^\\s*(\\s*/[*].*[*]/\\s*)*[}\\])]|^\\s*()" \ No newline at end of file + 'decreaseIndentPattern': "^\\s*(\\s*/[*].*[*]/\\s*)*[}\\])]|^\\s*()" From 9954068f8f73261e7cc9b1bbcf3bca4491282086 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Aug 2023 19:34:41 -0700 Subject: [PATCH 24/46] Fix syntax highlighting of Ruby regexes --- packages/language-ruby/grammars/ts/regex/highlights.scm | 2 -- packages/language-ruby/lib/main.js | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/language-ruby/grammars/ts/regex/highlights.scm b/packages/language-ruby/grammars/ts/regex/highlights.scm index 85255d818a..b0018b6c77 100644 --- a/packages/language-ruby/grammars/ts/regex/highlights.scm +++ b/packages/language-ruby/grammars/ts/regex/highlights.scm @@ -3,8 +3,6 @@ ; * No support for lookbehind as of March 2023 (waiting on ; https://github.com/tree-sitter/tree-sitter-regex/pull/15) -(pattern) @string.regexp - (non_capturing_group) @meta.group.non-capturing.regexp [ diff --git a/packages/language-ruby/lib/main.js b/packages/language-ruby/lib/main.js index df1a0041f1..5f343a42f5 100644 --- a/packages/language-ruby/lib/main.js +++ b/packages/language-ruby/lib/main.js @@ -1,4 +1,4 @@ -exports.activate = function() { +exports.activate = function () { if (!atom.grammars.addInjectionPoint) return; atom.grammars.addInjectionPoint('source.ruby', { @@ -19,6 +19,7 @@ exports.activate = function() { content(node) { return node; }, + languageScope: null, includeChildren: true, // coverShallowerScopes: false }); From ebf5333022451b7855c971db6a8c1fab8a8019f1 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Mon, 21 Aug 2023 00:46:29 -0700 Subject: [PATCH 25/46] [language-c] Scope identifiers as types when they are unambiguously so Anything that is one of the reserved type words in C must be a type in all contexts. And any identifier that ends in `_t` is, by strong convention, a type. --- .../language-c/grammars/tree-sitter-c/highlights.scm | 10 ++++++++++ .../grammars/tree-sitter-cpp/highlights.scm | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/language-c/grammars/tree-sitter-c/highlights.scm b/packages/language-c/grammars/tree-sitter-c/highlights.scm index 51778a17d9..a85ee59771 100644 --- a/packages/language-c/grammars/tree-sitter-c/highlights.scm +++ b/packages/language-c/grammars/tree-sitter-c/highlights.scm @@ -46,6 +46,16 @@ (primitive_type) @storage.type.builtin.c (type_identifier) @storage.type.other.c +; These types are all reserved words; if we see an identifier with this name, +; it must be a type. +((identifier) @storage.type.builtin.c + (#match? @storage.type.builtin.c "^(char|int|float|double|long)$")) + +; Assume any identifier that ends in `_t` is a type. This convention is not +; always followed, but it's a very strong indicator when it's present. +((identifier) @storage.type.other.c + (#match? @storage.type.other.c "_t$")) + [ "enum" "long" diff --git a/packages/language-c/grammars/tree-sitter-cpp/highlights.scm b/packages/language-c/grammars/tree-sitter-cpp/highlights.scm index 634aa8535a..ed0d2ebc9e 100644 --- a/packages/language-c/grammars/tree-sitter-cpp/highlights.scm +++ b/packages/language-c/grammars/tree-sitter-cpp/highlights.scm @@ -58,6 +58,17 @@ (type_identifier) @storage.type.other.cpp ; (struct_specifier) @storage.type.cpp +; These types are all reserved words; if we see an identifier with this name, +; it must be a type. +((identifier) @storage.type.builtin.cpp + (#match? @storage.type.builtin.cpp "^(char|int|float|double|long)$")) + +; Assume any identifier that ends in `_t` is a type. This convention is not +; always followed, but it's a very strong indicator when it's present. +((identifier) @storage.type.other.cpp + (#match? @storage.type.other.cpp "_t$")) + + [ "enum" "long" From 490ff32237be2211777775bdea8cddb41da53b6e Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Sun, 27 Aug 2023 00:24:42 -0700 Subject: [PATCH 26/46] [language-yaml] Highlight single-quoted strings --- packages/language-yaml/grammars/tree-sitter/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/language-yaml/grammars/tree-sitter/highlights.scm b/packages/language-yaml/grammars/tree-sitter/highlights.scm index 14e10bfccf..0e30f273d7 100644 --- a/packages/language-yaml/grammars/tree-sitter/highlights.scm +++ b/packages/language-yaml/grammars/tree-sitter/highlights.scm @@ -35,6 +35,8 @@ ((string_scalar) @string.quoted.yaml) +(single_quote_scalar) @string.quoted.single.yaml + (double_quote_scalar) @string.quoted.double.yaml ((double_quote_scalar) @punctuation.definition.string.begin.yaml From 37e25ac49e18f906db80e1e02ebc7a4c5810c108 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Sun, 27 Aug 2023 00:33:40 -0700 Subject: [PATCH 27/46] [language-yaml] Add scopes for single-quoted string delimiters --- packages/language-yaml/grammars/tree-sitter/highlights.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/language-yaml/grammars/tree-sitter/highlights.scm b/packages/language-yaml/grammars/tree-sitter/highlights.scm index 0e30f273d7..83ef5ee70f 100644 --- a/packages/language-yaml/grammars/tree-sitter/highlights.scm +++ b/packages/language-yaml/grammars/tree-sitter/highlights.scm @@ -37,6 +37,12 @@ (single_quote_scalar) @string.quoted.single.yaml +((single_quote_scalar) @punctuation.definition.string.begin.yaml + (#set! adjust.endAfterFirstMatchOf "^'")) + +((single_quote_scalar) @punctuation.definition.string.end.yaml + (#set! adjust.startBeforeFirstMatchOf "'$")) + (double_quote_scalar) @string.quoted.double.yaml ((double_quote_scalar) @punctuation.definition.string.begin.yaml From 878ef168c2c6769293e2fb3424fe68f5b478a124 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Sun, 27 Aug 2023 00:48:48 -0700 Subject: [PATCH 28/46] [language-yaml] Fix deprecated predicate syntax --- packages/language-yaml/grammars/tree-sitter/highlights.scm | 4 ++-- packages/language-yaml/grammars/tree-sitter/indents.scm | 2 +- packages/language-yaml/grammars/tree-sitter/tags.scm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/language-yaml/grammars/tree-sitter/highlights.scm b/packages/language-yaml/grammars/tree-sitter/highlights.scm index 83ef5ee70f..2f45509bb7 100644 --- a/packages/language-yaml/grammars/tree-sitter/highlights.scm +++ b/packages/language-yaml/grammars/tree-sitter/highlights.scm @@ -4,11 +4,11 @@ (block_mapping_pair key: (_) @entity.name.tag.yaml - (#set! test.final true)) + (#set! capture.final true)) (flow_pair key: (_) @entity.name.tag.yaml - (#set! test.final true)) + (#set! capture.final true)) ; COMMENTS diff --git a/packages/language-yaml/grammars/tree-sitter/indents.scm b/packages/language-yaml/grammars/tree-sitter/indents.scm index 05dec1522b..1cf9c2ad27 100644 --- a/packages/language-yaml/grammars/tree-sitter/indents.scm +++ b/packages/language-yaml/grammars/tree-sitter/indents.scm @@ -1,4 +1,4 @@ (":" @indent - (#set! test.onlyIfLastTextOnRow true)) + (#is? test.lastTextOnRow true)) ["|" ">"] @indent diff --git a/packages/language-yaml/grammars/tree-sitter/tags.scm b/packages/language-yaml/grammars/tree-sitter/tags.scm index c5983fe84c..4d76571af5 100644 --- a/packages/language-yaml/grammars/tree-sitter/tags.scm +++ b/packages/language-yaml/grammars/tree-sitter/tags.scm @@ -1,6 +1,6 @@ (block_mapping_pair key: (_) @name - (#set! test.final true) + (#set! capture.final true) (#set! symbol.prependSymbolForNode parent.parent.parent.parent.parent.parent.parent.firstNamedChild) (#set! symbol.joiner ".")) From 7d783657203d9058c29b7e91c5c1ec2156e11b1f Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Thu, 7 Sep 2023 19:53:50 -0700 Subject: [PATCH 29/46] Avoid hitting the API for packages if they are bundled --- packages/settings-view/lib/package-card.js | 52 +++++++++++++--------- src/atom-environment.js | 3 +- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/packages/settings-view/lib/package-card.js b/packages/settings-view/lib/package-card.js index 15845201cd..6b31a5059c 100644 --- a/packages/settings-view/lib/package-card.js +++ b/packages/settings-view/lib/package-card.js @@ -280,31 +280,39 @@ export default class PackageCard { } loadCachedMetadata () { - this.client.avatar(ownerFromRepository(this.pack.repository), (err, avatarPath) => { - if (!err && avatarPath) { - this.refs.avatar.src = `file://${avatarPath}` - } - }) - - this.client.package(this.pack.name, (err, data) => { - // We don't need to actually handle the error here, we can just skip - // showing the download count if there's a problem. - if (!err) { - if (data == null) { - data = {} + if (this.pack.repository === atom.branding.urlCoreRepo) { + // Don't hit the web for our bundled packages. Just use the local image. + this.refs.avatar.src = `file://${path.join(process.execPath, "..", "resources", "pulsar.png")}`; + } else { + this.client.avatar(ownerFromRepository(this.pack.repository), (err, avatarPath) => { + if (!err && avatarPath) { + this.refs.avatar.src = `file://${avatarPath}` } + }) + } - if (this.pack.apmInstallSource && this.pack.apmInstallSource.type === 'git') { - this.refs.downloadIcon.classList.remove('icon-cloud-download') - this.refs.downloadIcon.classList.add('icon-git-branch') - this.refs.downloadCount.textContent = this.pack.apmInstallSource.sha.substr(0, 8) - } else { - - this.refs.stargazerCount.textContent = data.stargazers_count ? parseInt(data.stargazers_count).toLocaleString() : '' - this.refs.downloadCount.textContent = data.downloads ? parseInt(data.downloads).toLocaleString() : '' + // We don't want to hit the API for this data, if it's a bundled package + if (this.pack.repository !== atom.branding.urlCoreRepo) { + this.client.package(this.pack.name, (err, data) => { + // We don't need to actually handle the error here, we can just skip + // showing the download count if there's a problem. + if (!err) { + if (data == null) { + data = {} + } + + if (this.pack.apmInstallSource && this.pack.apmInstallSource.type === 'git') { + this.refs.downloadIcon.classList.remove('icon-cloud-download') + this.refs.downloadIcon.classList.add('icon-git-branch') + this.refs.downloadCount.textContent = this.pack.apmInstallSource.sha.substr(0, 8) + } else { + + this.refs.stargazerCount.textContent = data.stargazers_count ? parseInt(data.stargazers_count).toLocaleString() : '' + this.refs.downloadCount.textContent = data.downloads ? parseInt(data.downloads).toLocaleString() : '' + } } - } - }) + }) + } } updateInterfaceState () { diff --git a/src/atom-environment.js b/src/atom-environment.js index 13682f3e76..cf20b2c870 100644 --- a/src/atom-environment.js +++ b/src/atom-environment.js @@ -222,7 +222,8 @@ class AtomEnvironment { name: packagejson.branding.name, urlWeb: packagejson.branding.urlWeb, urlGH: packagejson.branding.urlGH, - urlForum: packagejson.branding.urlForum + urlForum: packagejson.branding.urlForum, + urlCoreRepo: packagejson.repository.url }; // Keep instances of HistoryManager in sync From 07b50d9751526b7432aac110ecf008ff7f812e6a Mon Sep 17 00:00:00 2001 From: confused_techie Date: Mon, 11 Sep 2023 07:57:26 -0700 Subject: [PATCH 30/46] Remove `.git` from `repository.url` in the `package.json` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a85921a742..bf7430237d 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "main": "./src/main-process/main.js", "repository": { "type": "git", - "url": "https://github.com/pulsar-edit/pulsar.git" + "url": "https://github.com/pulsar-edit/pulsar" }, "bugs": { "url": "https://github.com/pulsar-edit/pulsar/issues" From 7312ae4f8301c509b7dd512c2a176ba7b440738a Mon Sep 17 00:00:00 2001 From: confused_techie Date: Mon, 11 Sep 2023 08:58:40 -0700 Subject: [PATCH 31/46] Import path correctly --- packages/settings-view/lib/package-card.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/settings-view/lib/package-card.js b/packages/settings-view/lib/package-card.js index 6b31a5059c..4affeb3676 100644 --- a/packages/settings-view/lib/package-card.js +++ b/packages/settings-view/lib/package-card.js @@ -5,6 +5,7 @@ import {CompositeDisposable, Disposable} from 'atom' import {shell} from 'electron' import etch from 'etch' import BadgeView from './badge-view' +import path from 'path' import {ownerFromRepository} from './utils' From e9903ad9d6602f90d6146fedeab1071144b1049c Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Mon, 11 Sep 2023 15:14:19 -0700 Subject: [PATCH 32/46] =?UTF-8?q?Change=20behavior=20of=20=E2=80=9Cadjustm?= =?UTF-8?q?ent=20exceeds=20bounds=E2=80=9D=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, we threw an error when a scope adjustment violated its bounds constraints, but that's a bit disruptive for everyday use. Instead, we throw an error in dev mode (so that the grammar's author doesn't fail to notice the problem), but downgrade it to a warning outside of dev mode so that it's recoverable. There's a chance that the warning will be _too_ subtle, but we'll give it a shot. We also include more diagnostic information so that it's clearer exactly _where_ the violation is happening. --- spec/scope-resolver-spec.js | 2 +- src/scope-resolver.js | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/spec/scope-resolver-spec.js b/spec/scope-resolver-spec.js index 5f7611d87d..ccd2af6b2b 100644 --- a/spec/scope-resolver-spec.js +++ b/spec/scope-resolver-spec.js @@ -228,7 +228,7 @@ describe('ScopeResolver', () => { let bar = "this is a line below a comment" `); // Prevent an exception from being thrown before we can even check the - // scopeResovler. + // scopeResolver. spyOn(languageMode, 'isRowCommented').andReturn(false); await languageMode.ready; diff --git a/src/scope-resolver.js b/src/scope-resolver.js index 5ce0a33dd2..559389bf40 100644 --- a/src/scope-resolver.js +++ b/src/scope-resolver.js @@ -16,6 +16,11 @@ function comparePoints(a, b) { } } +function rangeSpecToString (range) { + let [sp, ep] = [range.startPosition, range.endPosition]; + return `(${sp.row}, ${sp.column}) - (${ep.row}, ${ep.column})`; +} + function resolveNodeDescriptor(node, descriptor) { let parts = descriptor.split('.'); let result = node; @@ -266,6 +271,20 @@ class ScopeResolver { return ScopeResolver.CAPTURE_SETTINGS[prop](...args); } + warnAboutExceededRange(range, capture) { + let msg = ['Cannot extend past original range of capture!']; + + msg.push(`Scope name: ${capture.name}`); + msg.push(`Original range: ${rangeSpecToString(capture.node)}`); + msg.push(`Adjusted range: ${rangeSpecToString(range)}`); + + if (atom.inDevMode()) { + throw new Error(msg.join('\n')); + } + + console.warn(msg.join('\n')); + } + // Given a capture and possible predicate data, determines the buffer range // that this capture wants to cover. determineCaptureRange(capture) { @@ -299,7 +318,7 @@ class ScopeResolver { } if (this.rangeExceedsBoundsOfCapture(range, capture)) { - throw new Error('Cannot extend past original range of capture'); + this.warnAboutExceededRange(range, capture); } // Any invalidity in the returned range means we shouldn't store this From 152b80e524cbf5479e730629ab61150d9ce2993c Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 13 Sep 2023 15:36:48 -0400 Subject: [PATCH 33/46] Cirrus: Don't update last good commit if CI skipped For builds that are effectively skipped, since their tasks are all skipped or not scheduled in the first place, we shouldn't update CIRRUS_LAST_GREEN_CHANGE. Unfortunately, Cirrus *does* update that for builds with no or all-skipped tasks, for now. They may fix it in the future, we have a feature request open for it. But for now, this is the workaround. --- .cirrus.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index 5474df4510..f7159e7a55 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -263,3 +263,15 @@ silicon_mac_task: # path: report.xml # type: text/xml # format: junit + +silently_mark_skipped_or_no_scheduled_tasks_builds_as_failed_task: + skip_notifications: true + only_if: $CIRRUS_CRON == "" && $CIRRUS_TAG == "" + ### !!! ^ Don't forget to update this appropriately if our `only_if:` or `skip:` logic changes for the other tasks! !!! ### + ### !!! ^ We want this task to run [only] if all other tasks would have skipped. !!! ### + container: + image: alpine:latest + cpu: 1 + clone_script: exit 0 # Shortest possible script that succeeds. Saves time vs actually cloning. Failing here triggers an automatic re-run, so don't do that! + mark_task_as_failed_script: exit 1 # Shortest possible script to mark a build as "failed". This protects CIRRUS_LAST_GREEN_CHANGE from being updated by builds that actually just skipped CI. + timeout_in: 6s From e288139636ce635bdde80c59fe8dd57ad8274846 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 13 Sep 2023 18:22:12 -0400 Subject: [PATCH 34/46] about: Make the about page's CSS responsive for narrow panes --- packages/about/lib/components/about-view.js | 13 +++++----- packages/about/styles/about.less | 28 +++++++++++++++++++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/packages/about/lib/components/about-view.js b/packages/about/lib/components/about-view.js index 27425a19f2..0e2d0f2049 100644 --- a/packages/about/lib/components/about-view.js +++ b/packages/about/lib/components/about-view.js @@ -83,7 +83,7 @@ module.exports = class AboutView extends EtchComponent { return $.div( { className: 'pane-item native-key-bindings about' }, $.div( - { className: 'about-container' }, + { className: 'about-container min-width-min-content' }, $.header( { className: 'about-header' }, $.a( @@ -94,7 +94,7 @@ module.exports = class AboutView extends EtchComponent { { className: 'about-header-info' }, $.span( { - className: 'about-version-container inline-block atom', + className: 'about-version-container atom', onclick: this.handleAtomVersionClick.bind(this) }, $.span( @@ -114,7 +114,7 @@ module.exports = class AboutView extends EtchComponent { $.span( { className: - 'about-version-container inline-block show-more-expand', + 'about-version-container show-more-expand', onclick: this.handleShowMoreClick.bind(this) }, $.span({ className: 'about-more-expand' }, 'Show more') @@ -168,7 +168,7 @@ module.exports = class AboutView extends EtchComponent { ), $.div( - { className: 'about-updates group-start' }, + { className: 'about-updates group-start min-width-min-content' }, $.div( { className: 'about-updates-box' }, $.div( @@ -177,7 +177,7 @@ module.exports = class AboutView extends EtchComponent { { className: 'about-updates-item app-unsupported' }, $.span( { className: 'about-updates-label is-strong' }, - 'Updates have been moved to the package ', $.code({}, 'pulsar-updater'), '.', + 'Updates have been moved to the package ', $.code({style: {'white-space': 'nowrap'}}, 'pulsar-updater'), '.', $.br() ), $.a( @@ -242,7 +242,8 @@ module.exports = class AboutView extends EtchComponent { className: 'btn about-update-action-button', onclick: this.executeUpdateAction.bind(this), style: { - display: 'block' + display: 'block', + margin: '0 .5em' } }, 'Check Now' diff --git a/packages/about/styles/about.less b/packages/about/styles/about.less index 0b0e408f2e..14fb3d3ed9 100644 --- a/packages/about/styles/about.less +++ b/packages/about/styles/about.less @@ -33,6 +33,10 @@ margin-top: -.2em; } + .min-width-min-content { + min-width: min-content; + } + // used to group different elements .group-start { margin-top: 4em; @@ -45,8 +49,13 @@ .about-container { width: 100%; max-width: 500px; + + .icon::before { + margin-right: 0; + } } + // Header -------------------------------- .about-atom-io:hover { @@ -64,7 +73,18 @@ transition: color 0.2s; } +.about-header-info { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; + column-gap: .8em; + column-gap: 30px; +} + .about-version-container { + vertical-align: middle; + white-space: nowrap; &:hover { color: lighten(@text-color, 15%); } @@ -84,17 +104,19 @@ font-size: .9em; } +/* .about-header-release-notes { vertical-align: middle; margin-left: 1em; } +*/ // Updates -------------------------------- .about-updates { width: 100%; - //max-width: 510px; + max-width: 39em; } .about-updates-box { @@ -130,7 +152,7 @@ .about-updates-release-notes, .about-updates-instructions { - margin: 0 1em 0 1.5em; + // margin: 0 1em 0 1.5em; } .about-auto-updates { @@ -144,6 +166,8 @@ // Love -------------------------------- .about-love { + min-width: max-content; + .icon::before { // Make these octicons look good inlined with text position: relative; From 03033361c84a6f4a0c8f46ca152e097802b134ef Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 13 Sep 2023 22:06:21 -0400 Subject: [PATCH 35/46] about: Delete a redundant CSS rule This line was already overridden by the line right below it anyway... --- packages/about/styles/about.less | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/about/styles/about.less b/packages/about/styles/about.less index 14fb3d3ed9..6d85b80cc7 100644 --- a/packages/about/styles/about.less +++ b/packages/about/styles/about.less @@ -78,10 +78,8 @@ flex-wrap: wrap; justify-content: center; align-items: center; - column-gap: .8em; column-gap: 30px; } - .about-version-container { vertical-align: middle; white-space: nowrap; From 89c082dcc52f45e40128160c08173f18c4f1bf14 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Thu, 14 Sep 2023 03:43:55 -0400 Subject: [PATCH 36/46] about: Delete commented out CSS styles/rules --- packages/about/styles/about.less | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/about/styles/about.less b/packages/about/styles/about.less index 6d85b80cc7..fb7f23e3ba 100644 --- a/packages/about/styles/about.less +++ b/packages/about/styles/about.less @@ -102,13 +102,6 @@ font-size: .9em; } -/* -.about-header-release-notes { - vertical-align: middle; - margin-left: 1em; -} -*/ - // Updates -------------------------------- @@ -148,11 +141,6 @@ margin: 0 .4em; } -.about-updates-release-notes, -.about-updates-instructions { - // margin: 0 1em 0 1.5em; -} - .about-auto-updates { margin-top: 1em; input { From 79820ef760394ce072a84a9801515a97365668b0 Mon Sep 17 00:00:00 2001 From: Spiker985 <7829451+Spiker985@users.noreply.github.com> Date: Thu, 14 Sep 2023 18:50:55 -0400 Subject: [PATCH 37/46] Remove @ from example to fix Documentation CI Coffeescript function calls are prefixed with an @, which is the same syntax that jsdoc uses for parsing - which meant that it thought the example was empty. --- packages/tree-view/lib/tree-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tree-view/lib/tree-view.js b/packages/tree-view/lib/tree-view.js index 3ab1629e4a..f2caf3f736 100644 --- a/packages/tree-view/lib/tree-view.js +++ b/packages/tree-view/lib/tree-view.js @@ -1732,7 +1732,7 @@ * @function selectedPaths * @desc Public: Return an array of paths from all selected items * @example - * @selectedPaths() => ['selected/path/one', 'selected/path/two', 'selected/path/three' ] + * selectedPaths() => [ 'selected/path/one', 'selected/path/two', 'selected/path/three' ] * @returns {array} Selected item paths */ TreeView.prototype.selectedPaths = function() { From b79644e90b2e271c46b798ecad2ad4a659ec2567 Mon Sep 17 00:00:00 2001 From: confused_techie Date: Thu, 14 Sep 2023 22:40:26 -0700 Subject: [PATCH 38/46] Update packages/settings-view/lib/package-card.js Co-authored-by: DeeDeeG --- packages/settings-view/lib/package-card.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/settings-view/lib/package-card.js b/packages/settings-view/lib/package-card.js index 4affeb3676..f19f4eba95 100644 --- a/packages/settings-view/lib/package-card.js +++ b/packages/settings-view/lib/package-card.js @@ -283,7 +283,7 @@ export default class PackageCard { loadCachedMetadata () { if (this.pack.repository === atom.branding.urlCoreRepo) { // Don't hit the web for our bundled packages. Just use the local image. - this.refs.avatar.src = `file://${path.join(process.execPath, "..", "resources", "pulsar.png")}`; + this.refs.avatar.src = `file://${path.join(process.resourcesPath, "pulsar.png")}`; } else { this.client.avatar(ownerFromRepository(this.pack.repository), (err, avatarPath) => { if (!err && avatarPath) { From 5dec09add06e3ac87e4dd727b032f90e71d746f1 Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Thu, 14 Sep 2023 23:43:57 -0700 Subject: [PATCH 39/46] Use helper function to ensure we always get repository URL --- packages/settings-view/lib/package-card.js | 4 ++-- packages/settings-view/lib/utils.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/settings-view/lib/package-card.js b/packages/settings-view/lib/package-card.js index f19f4eba95..76cf45a0b3 100644 --- a/packages/settings-view/lib/package-card.js +++ b/packages/settings-view/lib/package-card.js @@ -7,7 +7,7 @@ import etch from 'etch' import BadgeView from './badge-view' import path from 'path' -import {ownerFromRepository} from './utils' +import {ownerFromRepository, repoUrlFromRepository} from './utils' let marked = null @@ -281,7 +281,7 @@ export default class PackageCard { } loadCachedMetadata () { - if (this.pack.repository === atom.branding.urlCoreRepo) { + if (repoUrlFromRepository(this.pack.repository) === atom.branding.urlCoreRepo) { // Don't hit the web for our bundled packages. Just use the local image. this.refs.avatar.src = `file://${path.join(process.resourcesPath, "pulsar.png")}`; } else { diff --git a/packages/settings-view/lib/utils.js b/packages/settings-view/lib/utils.js index 0bd3c4b8e3..e3fcb8585c 100644 --- a/packages/settings-view/lib/utils.js +++ b/packages/settings-view/lib/utils.js @@ -19,6 +19,18 @@ const ownerFromRepository = repository => { return match ? match[1] : '' } +const repoUrlFromRepository = repository => { + if (!repository) return '' + + if (typeof repository === 'string') { + return repository + } else if (typeof repository === 'object' && typeof repository.url === 'string') { + return repository.url + } else { + return '' + } +} + const packageComparatorAscending = (left, right) => { const leftStatus = atom.packages.isPackageDisabled(left.name) const rightStatus = atom.packages.isPackageDisabled(right.name) @@ -37,4 +49,4 @@ const packageComparatorAscending = (left, right) => { } } -module.exports = {ownerFromRepository, packageComparatorAscending} +module.exports = {ownerFromRepository, repoUrlFromRepository, packageComparatorAscending} From 9e94ca1b6c4df2f564f843f044c58a5a0252787b Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Fri, 15 Sep 2023 00:04:04 -0700 Subject: [PATCH 40/46] Ensure we strip the repo of `.git` --- packages/settings-view/lib/utils.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/settings-view/lib/utils.js b/packages/settings-view/lib/utils.js index e3fcb8585c..70974cacf2 100644 --- a/packages/settings-view/lib/utils.js +++ b/packages/settings-view/lib/utils.js @@ -22,13 +22,21 @@ const ownerFromRepository = repository => { const repoUrlFromRepository = repository => { if (!repository) return '' + let repo = repository + if (typeof repository === 'string') { - return repository + repo = repository } else if (typeof repository === 'object' && typeof repository.url === 'string') { - return repository.url + repo = repository.url } else { - return '' + repo = '' } + + if (repo.endsWith('.git')) { + repo = repo.replace('.git', '') + } + + return repo } const packageComparatorAscending = (left, right) => { From 3f778629906c3659c6453ee533d4533da9950cd6 Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Fri, 15 Sep 2023 16:18:49 -0700 Subject: [PATCH 41/46] Add new Changelog notes --- CHANGELOG.md | 42 ++++++++++++++++++++++++++ packages/welcome/lib/changelog-view.js | 26 +++++----------- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f7462f1af..d50e4ef204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,48 @@ ## [Unreleased] +## 1.109.0 + +- Fixed a race condition that could cause `autocomplete-plus` to ignore user input. +- Fixed the `about` package linking to release notes for Pulsar. +- Fixed the icon used when registering Pulsar as a file handler on Windows. +- Removed the `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package. +- Prevented warnings in the developer console from appearing when autocomplete suggestions are shown. +- Removed all CoffeeScript code from Pulsar and core packages. +- Migrated the majority of our CI to GitHub Actions. + +### Pulsar +- Fixed: Remove @ from example to fix Documentation CI [@Spiker985](https://github.com/pulsar-edit/pulsar/pull/719) +- Fixed: Cirrus: Don't update last good commit if CI skipped [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/716) +- Fixed: Tree-sitter running fixes (August edition) [@savetheclocktower](https://github.com/pulsar-edit/pulsar/pull/677) +- Added: [status-bar & tree-view] Manual Decaf Source [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/707) +- Added: [core] Consolidate app detail logic into single module [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/705) +- Fixed: [about] Link release notes to `CHANGELOG.md` instead of tagged release of Pulsar [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/706) +- Removed: Remove `fs-plus` from atom-protocol-handler [@Sertonix](https://github.com/pulsar-edit/pulsar/pull/170) +- Fixed: [core] Fix the icon used when registering Pulsar as a file handler in Windows [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/704) +- Added: Decaf Packages Spec [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/700) +- Removed: settings-view: Don't fix repository for core themes [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/702) +- Added: Cirrus: Skip builds if same commit was previously built [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/701) +- Fixed: CI: Tweak Cirrus build filter to allow tag pushes [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/699) +- Added: Automatically rename binaries in CI during Regular releases [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/675) +- Removed: remove repository fallback [@Sertonix](https://github.com/pulsar-edit/pulsar/pull/264) +- Added: [meta] GitHub Actions: Don't sign macOS builds from forked repo PRs [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/698) +- Added: [meta] Ensure Actions can upload Rolling Releases [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/695) +- Added: [meta] Cleanup `push` trigger, add `workflow_dispatch` [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/694) +- Added: Migrate most binary building to GitHub Actions [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/682) +- Added: [meta] Add `ignorePaths` to renovate config [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/691) +- Added: [language- && packages] Manual Decaf Spec Bundle [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/686) +- Fixed: fix links of packages readme [@asiloisad](https://github.com/pulsar-edit/pulsar/pull/689) +- Added: [meta] Add new and missing packages to renovate config [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/687) +- Added: Small Update to Docs [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/621) +- Fixed: [autocomplete-plus] Detect when menu state gets out of sync with DOM [@savetheclocktower](https://github.com/pulsar-edit/pulsar/pull/680) +- Removed: Remove AutoUpdate functionality from Core [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/668) +- Bumped: Update autocomplete-html package [@renovate](https://github.com/pulsar-edit/pulsar/pull/688) +- Added: [core]: Make showing tab title in window title optional [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/671) +- Fixed: [autocomplete-plus] Suppress `marked` warnings [@savetheclocktower](https://github.com/pulsar-edit/pulsar/pull/683) +- Added: [pulsar-updater] Don't notify if Pulsar is running via `yarn start` [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/679) +- Bumped: bump actions/checkout to v3 [@casswedson](https://github.com/pulsar-edit/pulsar/pull/678) + ## 1.108.0 - Restored ability for `less` files in packages to use inline JavaScript inside backticks. diff --git a/packages/welcome/lib/changelog-view.js b/packages/welcome/lib/changelog-view.js index 460694ebdd..f24c469909 100644 --- a/packages/welcome/lib/changelog-view.js +++ b/packages/welcome/lib/changelog-view.js @@ -50,40 +50,28 @@ export default class ChangeLogView {

Feel free to read our Full Change Log.

  • - Restored ability for `less` files in packages to use inline JavaScript inside backticks. + Fixed a race condition that could cause `autocomplete-plus` to ignore user input.
  • - Fixed a syntax highlighting issue inside the `styleguide` package. + Fixed the `about` package linking to release notes for Pulsar.
  • - Fixed an issue with rubygems timing out on ARM Linux workflow. + Fixed the icon used when registering Pulsar as a file handler on Windows.
  • - Rewrote Tree-sitter scope predicates to use `#is?` and `#is-not?` where applicable. + Removed the `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package.
  • Ensure that project-specific setting overrides don't leak to the user's config file when the settings UI is visited.
  • - Added a feature in `markdown-preview` that adds support for Linguist, Chroma, Rouge, and HighlightJS for - language identifiers in fenced code blocks. + Prevented warnings in the developer console from appearing when autocomplete suggestions are shown.
  • - Fixed the `TextMate` `language-toml` grammar to properly support whitespace where-ever it may appear. + Removed all CoffeeScript code from Pulsar and core packages.
  • - Added a Tree-Sitter grammar for YAML files. -
  • -
  • - Added a new core package `pulsar-updater` to help users update Pulsar. -
  • -
  • - Added `ppm` and `ppm.cmd` binaries/launchers within ppm. This allows easier integration of - correctly named binaries on more systems in more contexts (especially Windows). - Existing `apm` and `apm.cmd` binaries/launchers are still there for the time being. -
  • -
  • - Added a modern Tree-Sitter grammar for Markdown files. + Migrated the majority of our CI to GitHub Actions.
From ff481e3f86a7f6a3781cf94c74fd141811aa59c4 Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Fri, 15 Sep 2023 19:49:14 -0700 Subject: [PATCH 42/46] Add last PR merge --- CHANGELOG.md | 2 ++ packages/welcome/lib/changelog-view.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d50e4ef204..c5822c089e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Fixed a race condition that could cause `autocomplete-plus` to ignore user input. - Fixed the `about` package linking to release notes for Pulsar. +- Reduced the amount of network requests that `settings-view` does. - Fixed the icon used when registering Pulsar as a file handler on Windows. - Removed the `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package. - Prevented warnings in the developer console from appearing when autocomplete suggestions are shown. @@ -17,6 +18,7 @@ - Migrated the majority of our CI to GitHub Actions. ### Pulsar +- Added: [core & settings-view] Avoid network requests for bundled packages [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/711) - Fixed: Remove @ from example to fix Documentation CI [@Spiker985](https://github.com/pulsar-edit/pulsar/pull/719) - Fixed: Cirrus: Don't update last good commit if CI skipped [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/716) - Fixed: Tree-sitter running fixes (August edition) [@savetheclocktower](https://github.com/pulsar-edit/pulsar/pull/677) diff --git a/packages/welcome/lib/changelog-view.js b/packages/welcome/lib/changelog-view.js index f24c469909..d2d9e325a7 100644 --- a/packages/welcome/lib/changelog-view.js +++ b/packages/welcome/lib/changelog-view.js @@ -55,6 +55,9 @@ export default class ChangeLogView {
  • Fixed the `about` package linking to release notes for Pulsar.
  • +
  • + Reduced the amount of network requests that `settings-view` creates. +
  • Fixed the icon used when registering Pulsar as a file handler on Windows.
  • From 10b31b3cf904f719a6c891263672b6f302badcbc Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Fri, 15 Sep 2023 19:50:42 -0700 Subject: [PATCH 43/46] Another last PR merged --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5822c089e..5562849f30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - Fixed a race condition that could cause `autocomplete-plus` to ignore user input. - Fixed the `about` package linking to release notes for Pulsar. -- Reduced the amount of network requests that `settings-view` does. +- Reduced the amount of network requests that `settings-view` creates. - Fixed the icon used when registering Pulsar as a file handler on Windows. - Removed the `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package. - Prevented warnings in the developer console from appearing when autocomplete suggestions are shown. @@ -18,6 +18,7 @@ - Migrated the majority of our CI to GitHub Actions. ### Pulsar +- Added: about: Make the About page's CSS responsive for narrow panes [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/717) - Added: [core & settings-view] Avoid network requests for bundled packages [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/711) - Fixed: Remove @ from example to fix Documentation CI [@Spiker985](https://github.com/pulsar-edit/pulsar/pull/719) - Fixed: Cirrus: Don't update last good commit if CI skipped [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/716) From 12fdc303676c279aae0380316d5effda42ef5414 Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Fri, 15 Sep 2023 20:28:16 -0700 Subject: [PATCH 44/46] Fix some items within Changelog --- CHANGELOG.md | 4 ++-- packages/welcome/lib/changelog-view.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5562849f30..2634d6f736 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,9 @@ - Fixed the `about` package linking to release notes for Pulsar. - Reduced the amount of network requests that `settings-view` creates. - Fixed the icon used when registering Pulsar as a file handler on Windows. -- Removed the `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package. +- Removed the non-functional `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package. - Prevented warnings in the developer console from appearing when autocomplete suggestions are shown. -- Removed all CoffeeScript code from Pulsar and core packages. +- Removed the last CoffeeScript code from Pulsar and core packages. - Migrated the majority of our CI to GitHub Actions. ### Pulsar diff --git a/packages/welcome/lib/changelog-view.js b/packages/welcome/lib/changelog-view.js index d2d9e325a7..ca37df4c75 100644 --- a/packages/welcome/lib/changelog-view.js +++ b/packages/welcome/lib/changelog-view.js @@ -62,7 +62,7 @@ export default class ChangeLogView { Fixed the icon used when registering Pulsar as a file handler on Windows.
  • - Removed the `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package. + Removed the non-functional `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package.
  • Ensure that project-specific setting overrides don't leak to the user's config file when the settings UI is visited. @@ -71,7 +71,7 @@ export default class ChangeLogView { Prevented warnings in the developer console from appearing when autocomplete suggestions are shown.
  • - Removed all CoffeeScript code from Pulsar and core packages. + Removed the last CoffeeScript code from Pulsar and core packages.
  • Migrated the majority of our CI to GitHub Actions. From 91ef3d325829e5e689c8d8128a9e64e6ee77a874 Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Fri, 15 Sep 2023 20:29:51 -0700 Subject: [PATCH 45/46] Bump `package.json` version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf7430237d..a4fc9baa2c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "pulsar", "author": "Pulsar-Edit ", "productName": "Pulsar", - "version": "1.108.0-dev", + "version": "1.109.0", "description": "A Community-led Hyper-Hackable Text Editor", "branding": { "id": "pulsar", From 7984564a92569c03e3b0a60dbdb77468fb768f2d Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Fri, 15 Sep 2023 23:41:51 -0700 Subject: [PATCH 46/46] Add back dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4fc9baa2c..15cc3f49a9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "pulsar", "author": "Pulsar-Edit ", "productName": "Pulsar", - "version": "1.109.0", + "version": "1.109.0-dev", "description": "A Community-led Hyper-Hackable Text Editor", "branding": { "id": "pulsar",