aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2023-04-24 19:10:49 -0400
committerAmaan Qureshi <amaanq12@gmail.com>2023-04-25 02:37:31 -0400
commit9f157094cd0dabb7a6fd240e38b00d4ed0176fdb (patch)
treee6341fc2fc8fd06bbe7e76826daa923a31fc3b6c
parentinjections(lua): highlight vim.api.nvim_exec2 (diff)
downloadnvim-treesitter-9f157094cd0dabb7a6fd240e38b00d4ed0176fdb.tar
nvim-treesitter-9f157094cd0dabb7a6fd240e38b00d4ed0176fdb.tar.gz
nvim-treesitter-9f157094cd0dabb7a6fd240e38b00d4ed0176fdb.tar.bz2
nvim-treesitter-9f157094cd0dabb7a6fd240e38b00d4ed0176fdb.tar.lz
nvim-treesitter-9f157094cd0dabb7a6fd240e38b00d4ed0176fdb.tar.xz
nvim-treesitter-9f157094cd0dabb7a6fd240e38b00d4ed0176fdb.tar.zst
nvim-treesitter-9f157094cd0dabb7a6fd240e38b00d4ed0176fdb.zip
feat(smali): update queries from upstream parser
-rw-r--r--lockfile.json2
-rw-r--r--lua/nvim-treesitter/parsers.lua2
-rw-r--r--queries/smali/highlights.scm46
3 files changed, 40 insertions, 10 deletions
diff --git a/lockfile.json b/lockfile.json
index 9ad6d940f..45474c092 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -426,7 +426,7 @@
"revision": "07547525cdf4627343dca5891f1743ae45e879bb"
},
"smali": {
- "revision": "b002dceb9b91a6d6de45479ab4b2e9596ebbaaf3"
+ "revision": "9bf8aa671a233ae2d2c6e9512c7144ce121b1fb6"
},
"smithy": {
"revision": "cf8c7eb9faf7c7049839585eac19c94af231e6a0"
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 6a52a4a6e..b3fc36313 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -1269,7 +1269,7 @@ list.slint = {
list.smali = {
install_info = {
url = "https://git.sr.ht/~yotam/tree-sitter-smali",
- files = { "src/parser.c" },
+ files = { "src/parser.c", "src/scanner.c" },
},
maintainers = { "@amaanq" },
}
diff --git a/queries/smali/highlights.scm b/queries/smali/highlights.scm
index e9ec9c22c..2e2b84b8b 100644
--- a/queries/smali/highlights.scm
+++ b/queries/smali/highlights.scm
@@ -1,11 +1,21 @@
; Types
-(class_identifier) @type
+(class_identifier
+ (identifier) @type)
(primitive_type) @type.builtin
-((class_identifier) @type.builtin
- (#match? @type.builtin "^L(android|com/android|dalvik|java|kotlinx)/"))
+((class_identifier
+ . (identifier) @_first @type.builtin
+ (identifier) @type.builtin)
+ (#any-of? @_first "android" "dalvik" "java" "kotlinx"))
+
+((class_identifier
+ . (identifier) @_first @type.builtin
+ . (identifier) @_second @type.builtin
+ (identifier) @type.builtin)
+ (#eq? @_first "com")
+ (#any-of? @_second "android" "google"))
; Methods
@@ -48,6 +58,8 @@
((method_identifier) @constructor
(#any-of? @constructor "<init>" "<clinit>"))
+"constructor" @constructor
+
; Fields
[
@@ -55,6 +67,9 @@
(annotation_key)
] @field
+((field_identifier) @constant
+ (#lua-match? @constant "^[%u_]*$"))
+
; Variables
(variable) @variable.builtin
@@ -90,6 +105,9 @@
((opcode) @exception
(#lua-match? @exception "^throw"))
+((opcode) @comment
+ (#eq? @comment "nop")) ; haha, anyone get it? ;)
+
[
"="
".."
@@ -100,7 +118,6 @@
[
".class"
".super"
- ".source"
".implements"
".field"
".end field"
@@ -118,8 +135,6 @@
".end local"
".restart local"
".registers"
- ".catch"
- ".catchall"
".packed-switch"
".end packed-switch"
".sparse-switch"
@@ -132,10 +147,19 @@
] @keyword
[
+ ".source"
+] @include
+
+[
".method"
".end method"
] @keyword.function
+[
+ ".catch"
+ ".catchall"
+] @exception
+
; Literals
(string) @string
@@ -144,6 +168,8 @@
(character) @character
+"L" @character.special
+
(number) @number
[
@@ -160,7 +186,7 @@
(annotation_visibility) @storageclass
-(access_modifiers) @type.qualifier
+(access_modifier) @type.qualifier
(array_type
"[" @punctuation.special)
@@ -171,11 +197,15 @@
[
"->"
- ":"
","
+ ":"
+ ";"
"@"
+ "/"
] @punctuation.delimiter
+(line_directive (number) @text.underline @text.literal)
+
; Comments
(comment) @comment @spell