From 1ae9b0e4558fe7868f8cda2db65239cfb14836d0 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 24 Dec 2023 10:00:20 +0100 Subject: feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md` --- .../highlights/smali/baksmali_test_class.smali | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/query/highlights/smali') diff --git a/tests/query/highlights/smali/baksmali_test_class.smali b/tests/query/highlights/smali/baksmali_test_class.smali index 77eb0c83b..6412f8784 100644 --- a/tests/query/highlights/smali/baksmali_test_class.smali +++ b/tests/query/highlights/smali/baksmali_test_class.smali @@ -7,18 +7,18 @@ # ^ @punctuation.delimiter .source "baksmali_test_class.smali" -# <- @include +# <- @keyword.import .implements Lsome/interface; .implements Lsome/other/interface; .annotation build Lsome/annotation; -# ^^^^^ @storageclass +# ^^^^^ @keyword.storage # ^^^^ @type # ^ @punctuation.delimiter value1 = "test" -# ^^^^^^ @field +# ^^^^^^ @variable.member # ^ @operator # ^^^^^^ @string value2 = .subannotation Lsome/annotation; @@ -50,7 +50,7 @@ .field public static byteNegStaticField:B = 0xAAt .field public static floatStaticField:F = 3.1415926f -# ^^^^^^^^^^ @float +# ^^^^^^^^^^ @number.float .field public static doubleStaticField:D = 3.141592653589793 @@ -73,7 +73,7 @@ .field public static methodStaticField:Ljava/lang/reflect/Method; = Lbaksmali/test/class;->testMethod(ILjava/lang/String;)Ljava/lang/String; # ^^ @punctuation.delimiter -# ^^^^^^^^^^ @method.call +# ^^^^^^^^^^ @function.method.call .field public static arrayStaticField:[I = {1, 2, 3, {1, 2, 3, 4}} # ^ @punctuation.special @@ -81,7 +81,7 @@ # ^ @punctuation.delimiter .field public static enumStaticField:Lsome/enum; = .enum Lsome/enum;->someEnumValue:Lsome/enum; -# ^^^^^^^^^^^^^ @field +# ^^^^^^^^^^^^^ @variable.member .field public static annotationStaticField:Lsome/annotation; = .subannotation Lsome/annotation; value1 = "test" @@ -93,7 +93,7 @@ .field public static staticFieldWithAnnotation:I .annotation runtime La/field/annotation; -# ^^^^^^^ @storageclass +# ^^^^^^^ @keyword.storage this = "is" a = "test" .end annotation @@ -112,13 +112,13 @@ .registers 1 invoke-direct {p0}, Ljava/lang/Object;->()V # ^^^^^^^^^^^^^ @keyword.operator -# ^^ @parameter.builtin +# ^^ @variable.parameter.builtin return-void # ^^^^^^^^^^^ @keyword.return .end method .method public testMethod(ILjava/lang/String;)Ljava/lang/String; -# ^^^^^^^^^^ @method +# ^^^^^^^^^^ @function.method .registers 3 .annotation runtime Lorg/junit/Test; .end annotation @@ -144,9 +144,9 @@ nop try_end: .catch Ljava/lang/Exception; {try_start: .. try_end:} handler: -# ^^^^^^ @exception +# ^^^^^^ @keyword.exception .catchall {try_start: .. try_end:} handler2: -# ^^^^^^^^^ @exception +# ^^^^^^^^^ @keyword.exception # ^^ @operator handler: @@ -232,9 +232,9 @@ nop .source "somefile.java" -# ^^^^^^^ @include +# ^^^^^^^ @keyword.import .line 101 -# ^^^ @text.literal +# ^^^ @string.special nop -- cgit v1.2.3-70-g09d2