From fdc3cfc0081883ea8918f7504c8c31151d78039e Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 14 Jun 2022 09:39:45 -0500 Subject: [PATCH 01/16] erlang: highlight nullary macros as constants --- runtime/queries/erlang/highlights.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index 0cb60ca99977..94f1e9f5a024 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -38,8 +38,8 @@ (arguments . [ - (atom) @keyword.directive - (variable) @keyword.directive + (atom) @constant + (variable) @constant (call function: [(variable) (atom)] @keyword.directive) @@ -99,6 +99,11 @@ (comment) @comment ; Macros +(macro + "?"+ @constant + name: (_) @constant + !arguments) + (macro "?"+ @keyword.directive name: (_) @keyword.directive) From 913b673d6f7c820752021009be3a6a1a464148f3 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 15 Jun 2022 15:25:11 -0500 Subject: [PATCH 02/16] erlang: highlight unary '#' as punctuation.bracket The '#' character may either be interpreted as a map when used like so: %% Example 1 #{a => b} Or as an operator which updates an existing map when the left-hand side is an expression: %% Example 2 MyMap#{a => b} This commit changes the highlight to `punctuation.bracket` when used as a character in a literal map (example 1) and keeps the `operator` highlight when used for updating (example 2). --- runtime/queries/erlang/highlights.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index 94f1e9f5a024..ce84697b572b 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -92,7 +92,7 @@ (binary_operator operator: _ @operator) (unary_operator operator: _ @operator) -["/" ":" "#" "->"] @operator +["/" ":" "->"] @operator (tripledot) @comment.discard @@ -123,6 +123,6 @@ ; Punctuation ["," "." "-" ";"] @punctuation.delimiter -["(" ")" "{" "}" "[" "]" "<<" ">>"] @punctuation.bracket +["(" ")" "#" "{" "}" "[" "]" "<<" ">>"] @punctuation.bracket ; (ERROR) @error From dd82c64a44d61ab0d40097cebc4d266ccbfcfc18 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 20:09:12 -0500 Subject: [PATCH 03/16] markdown: highlight punctuation --- runtime/queries/markdown/highlights.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/queries/markdown/highlights.scm b/runtime/queries/markdown/highlights.scm index 44b19741c512..aee568c8d570 100644 --- a/runtime/queries/markdown/highlights.scm +++ b/runtime/queries/markdown/highlights.scm @@ -47,3 +47,7 @@ (hard_line_break) ] @constant.character.escape +(thematic_break) @punctuation.delimiter + +(inline_link ["[" "]" "(" ")"] @punctuation.bracket) +(image ["[" "]" "(" ")"] @punctuation.bracket) From 84b5188d555d6e66cbdb04dcab3f078be5bacb90 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 20:09:30 -0500 Subject: [PATCH 04/16] bash: expand injection-regex to common shells --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 0e6cbb9cbe31..7a4b28c4c8a0 100644 --- a/languages.toml +++ b/languages.toml @@ -460,7 +460,7 @@ source = { git = "https://github.com/tree-sitter/tree-sitter-ruby", rev = "dfff6 [[language]] name = "bash" scope = "source.bash" -injection-regex = "bash" +injection-regex = "(shell|bash|zsh|sh)" file-types = ["sh", "bash", "zsh", ".bash_login", ".bash_logout", ".bash_profile", ".bashrc", ".profile", ".zshenv", ".zlogin", ".zlogout", ".zprofile", ".zshrc", "APKBUILD", "PKGBUILD", "eclass", "ebuild", "bazelrc"] shebangs = ["sh", "bash", "dash"] roots = [] From 521547e0a144b3a194428baac48bc6040da146df Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 20:10:19 -0500 Subject: [PATCH 05/16] rust: fix highlight corner-cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add punctuation highlights for commas as in function parameters * remove stray `variable.parameter` highlight * I couldn't find any regressions from this and it fixes an edge case I ran into (but sadly did not record 😓) * highlight `fn` as `keyword.function` * the theme docs have `fn` as an example so it seems fitting --- runtime/queries/rust/highlights.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm index 4b0c018e2e05..5897991ee52b 100644 --- a/runtime/queries/rust/highlights.scm +++ b/runtime/queries/rust/highlights.scm @@ -57,6 +57,7 @@ "::" "." ";" + "," ] @punctuation.delimiter [ @@ -95,8 +96,6 @@ value: (identifier)? @variable field: (field_identifier) @variable.other.member)) -(arguments - (identifier) @variable.parameter) (parameter pattern: (identifier) @variable.parameter) (closure_parameters @@ -141,7 +140,6 @@ "mod" "extern" - "fn" "struct" "enum" "impl" @@ -160,6 +158,8 @@ "async" ] @keyword +"fn" @keyword.function + (mutable_specifier) @keyword.storage.modifier.mut (reference_type "&" @keyword.storage.modifier.ref) From 53f2f58284d2b43e6fe1215e11ac387efd6132e0 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 22 Jun 2022 08:57:22 -0500 Subject: [PATCH 06/16] edoc: prevent rogue punctuation highlights Punctuation highlights would show up outside of where they were valid, for example using parentheses in some text. This change prevents that by gating the captures to being under the named nodes in which they are valid. --- runtime/queries/edoc/highlights.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/queries/edoc/highlights.scm b/runtime/queries/edoc/highlights.scm index 3a309960fe80..4267cb9e0b1f 100644 --- a/runtime/queries/edoc/highlights.scm +++ b/runtime/queries/edoc/highlights.scm @@ -39,9 +39,9 @@ ; could be @constant.numeric.integer but this looks similar to a capture (arity) @operator -[":" "/"] @operator -["(" ")"] @punctuation.delimiter -["{" "}"] @function.macro +(expression [":" "/"] @operator) +(expression ["(" ")"] @punctuation.delimiter) +(macro ["{" "}"] @function.macro) [ (quote_marker) From 141ce7f07a19874baadaece9dcbaf904bd4c2296 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 10:09:42 -0500 Subject: [PATCH 07/16] html: highlight punctuation * `/>` as in self-closing tags like `
` * `=` as in the separator between attribute name and value `` --- runtime/queries/html/highlights.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/queries/html/highlights.scm b/runtime/queries/html/highlights.scm index 2c70a9c3e6d5..fff015b5c674 100644 --- a/runtime/queries/html/highlights.scm +++ b/runtime/queries/html/highlights.scm @@ -2,11 +2,18 @@ (erroneous_end_tag_name) @tag.error (doctype) @constant (attribute_name) @attribute -(attribute_value) @string (comment) @comment +[ + "\"" + (attribute_value) +] @string + [ "<" ">" "" ] @punctuation.bracket + +"=" @punctuation.delimiter From 07e9d5fd557105cb558d01e2351dea3a6095f471 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 13:08:31 -0500 Subject: [PATCH 08/16] replace module captures with namespace `module` is undocumented and does not exist in other themes. The equivalent existing scope based on usage (Elixir for example) is `namespace`. --- runtime/queries/erlang/highlights.scm | 10 +++++----- runtime/queries/heex/highlights.scm | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index ce84697b572b..f491b9c5f29e 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -2,14 +2,14 @@ ; module declaration (attribute name: (atom) @keyword - (arguments (atom) @module) + (arguments (atom) @namespace) (#eq? @keyword "module")) (attribute name: (atom) @keyword (arguments . - (atom) @module) + (atom) @namespace) (#eq? @keyword "import")) (attribute @@ -54,15 +54,15 @@ (attribute name: (atom) @keyword - module: (atom) @module (#eq? @keyword "(spec|callback)")) + module: (atom) @namespace ; Functions (function_clause name: (atom) @function) -(call module: (atom) @module) +(call module: (atom) @namespace) (call function: (atom) @function) (stab_clause name: (atom) @function) -(function_capture module: (atom) @module) +(function_capture module: (atom) @namespace) (function_capture function: (atom) @function) ; Records diff --git a/runtime/queries/heex/highlights.scm b/runtime/queries/heex/highlights.scm index c42a689fc4c6..6d8816de97e2 100644 --- a/runtime/queries/heex/highlights.scm +++ b/runtime/queries/heex/highlights.scm @@ -55,7 +55,7 @@ ; HEEx components are highlighted as Elixir modules and functions (component_name [ - (module) @module + (module) @namespace (function) @function "." @punctuation.delimiter ]) From b6e2ea30244fd91ff6585bc45c8ea8f68c85be8e Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 13:08:59 -0500 Subject: [PATCH 09/16] erlang: fix '#match?' for specs/callbacks --- runtime/queries/erlang/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index f491b9c5f29e..31a594b696c6 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -54,8 +54,8 @@ (attribute name: (atom) @keyword - (#eq? @keyword "(spec|callback)")) module: (atom) @namespace + (#match? @keyword "(spec|callback)")) ; Functions (function_clause name: (atom) @function) From 4a4a671a5fdc1d0dbf1f906a970e4ac068a4a075 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 16:19:48 -0500 Subject: [PATCH 10/16] make: add injection-regex --- languages.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 7a4b28c4c8a0..f1b6c980ccb6 100644 --- a/languages.toml +++ b/languages.toml @@ -727,7 +727,8 @@ source = { git = "https://github.com/uyha/tree-sitter-cmake", rev = "f6616f1e417 name = "make" scope = "source.make" file-types = ["Makefile", "makefile", "mk", "justfile", ".justfile"] -roots =[] +injection-regex = "(make|makefile|Makefile|mk|just)" +roots = [] comment-token = "#" indent = { tab-width = 4, unit = "\t" } From 0a143b65e129b1c24eb33b5a99b4fb71c08f8f34 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 20:08:09 -0500 Subject: [PATCH 11/16] erlang: update parser for fix on remote calls --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index f1b6c980ccb6..2f209b4ff160 100644 --- a/languages.toml +++ b/languages.toml @@ -1052,7 +1052,7 @@ language-server = { command = "erlang_ls" } [[grammar]] name = "erlang" -source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "c0ebc82600caaf4339f2b00691f958e9df97c065" } +source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "0e7d677d11a7379686c53c616825714ccb728059" } [[language]] name = "kotlin" From b757da9e1dbcb1153d040be3019254dcf9fd4987 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 20:31:11 -0500 Subject: [PATCH 12/16] tsq: update parser to fix escaping double quotes This includes a fix for the new HTML highlights introduced a few parent commits back: ["\"" (attribute_name)] @string Would get tripped up and the entire line would be highlighted as a string. Now `\"` is a valid escape. I'm switching to my fork as the primary repo as the upstream hasn't been touched in over a year (mostly because stability afaict) but it has no watchers currently so I'm not hopeful that my PR will be merged. --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 2f209b4ff160..b8581080a503 100644 --- a/languages.toml +++ b/languages.toml @@ -707,7 +707,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "tsq" -source = { git = "https://github.com/tree-sitter/tree-sitter-tsq", rev = "b665659d3238e6036e22ed0e24935e60efb39415" } +source = { git = "https://github.com/the-mikedavis/tree-sitter-tsq", rev = "ea68fc2b571ca1c8f70936855130c380f518ff35" } [[language]] name = "cmake" From 52a14b40b614c66ce7829240b661448f7e003f71 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 28 Jun 2022 20:59:03 -0500 Subject: [PATCH 13/16] git-commit: fix highlight edge cases * branch message with current branch and diverged branch has been added to the parser * scissors used in verbose commits are marked as a punctuation delimiter * we could use comment instead since they're visually the same but IMO this works better --- languages.toml | 2 +- runtime/queries/git-commit/highlights.scm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages.toml b/languages.toml index b8581080a503..122cadfe80d7 100644 --- a/languages.toml +++ b/languages.toml @@ -908,7 +908,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "git-commit" -source = { git = "https://github.com/the-mikedavis/tree-sitter-git-commit", rev = "7ae23de633de41f8f5b802f6f05b6596df6d00c1" } +source = { git = "https://github.com/the-mikedavis/tree-sitter-git-commit", rev = "318dd72abfaa7b8044c1d1fbeabcd06deaaf038f" } [[language]] name = "git-diff" diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm index 0b50d41908f5..bdb776d6dd6a 100644 --- a/runtime/queries/git-commit/highlights.scm +++ b/runtime/queries/git-commit/highlights.scm @@ -10,5 +10,5 @@ (change kind: "modified" @diff.delta) (change kind: "renamed" @diff.delta.moved) -[":" "->"] @punctuation.delimeter +[":" "->" (scissors)] @punctuation.delimeter (comment) @comment From 709eb148eb9e4f85a9d1870c211e2a65377cb43c Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 29 Jun 2022 08:55:00 -0500 Subject: [PATCH 14/16] erlang: highlight records with macro names You might use a macro like `?MODULE` to name a record: -record(?MODULE, {a, b, c}). With this fix, the record fields correctly get `variable.other.member` highlights. --- runtime/queries/erlang/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index 31a594b696c6..cb128905ab2e 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -16,7 +16,7 @@ name: (atom) @keyword (arguments . - (atom) @type + [(atom) @type (macro)] [ (tuple (atom) @variable.other.member) (tuple From c916ceb98a7b6f2e19c4a0f9231b440def526ecc Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 29 Jun 2022 12:44:01 -0500 Subject: [PATCH 15/16] erlang: highlight modules in behaviour attributes --- runtime/queries/erlang/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index cb128905ab2e..8e4a640d6ecb 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -3,7 +3,7 @@ (attribute name: (atom) @keyword (arguments (atom) @namespace) - (#eq? @keyword "module")) + (#match? @keyword "(module|behaviou?r)")) (attribute name: (atom) @keyword From 00e5fa77722038eefdd8e3a2f2d903617029332e Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 30 Jun 2022 17:46:34 -0500 Subject: [PATCH 16/16] markdown: limit raw block highlight to code fence content --- languages.toml | 2 +- runtime/queries/markdown/highlights.scm | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/languages.toml b/languages.toml index 122cadfe80d7..0b4a1dec545a 100644 --- a/languages.toml +++ b/languages.toml @@ -855,7 +855,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "markdown" -source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "ad8c32917a16dfbb387d1da567bf0c3fb6fffde2" } +source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "ab15701d8f3f68aeb74e30573b7d669a6ef2a7ed" } [[language]] name = "dart" diff --git a/runtime/queries/markdown/highlights.scm b/runtime/queries/markdown/highlights.scm index aee568c8d570..096c29542622 100644 --- a/runtime/queries/markdown/highlights.scm +++ b/runtime/queries/markdown/highlights.scm @@ -8,11 +8,9 @@ (atx_heading (atx_h5_marker) @markup.heading.marker (heading_content) @markup.heading.5) (atx_heading (atx_h6_marker) @markup.heading.marker (heading_content) @markup.heading.6) -(code_fence_content) @none - [ (indented_code_block) - (fenced_code_block) + (code_fence_content) ] @markup.raw.block (block_quote) @markup.quote @@ -26,6 +24,8 @@ (link_destination) @markup.link.url (link_label) @markup.link.label +(info_string) @label + [ (link_text) (image_description) @@ -51,3 +51,4 @@ (inline_link ["[" "]" "(" ")"] @punctuation.bracket) (image ["[" "]" "(" ")"] @punctuation.bracket) +(fenced_code_block_delimiter) @punctuation.bracket