Skip to content

Commit

Permalink
chore!: parser updates again
Browse files Browse the repository at this point in the history
  • Loading branch information
RubixDev committed Feb 28, 2025
1 parent 60a0861 commit 77fbf5f
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 52 deletions.
17 changes: 17 additions & 0 deletions queries/ecma/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,23 @@
)
)

(call_expression
function: (await_expression
(identifier) @function.call
)
)

(call_expression
function: (await_expression
(member_expression
property: [
(property_identifier)
(private_property_identifier)
] @function.method.call
)
)
)

; Builtins
;---------
(
Expand Down
16 changes: 16 additions & 0 deletions queries/java/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
(#set! injection.language "doxygen")
)

; markdown-style javadocs: https://openjdk.org/jeps/467
(
(line_comment) @injection.content
(#lua-match? @injection.content "^///%s")
(#offset! @injection.content 0 4 0 0)
(#set! injection.language "markdown_inline")
)

; markdown-style javadocs: https://openjdk.org/jeps/467
(
(line_comment) @injection.content
(#lua-match? @injection.content "^///%s+[@]")
(#offset! @injection.content 0 4 0 0)
(#set! injection.language "doxygen")
)

(
(method_invocation
name: (identifier) @_method
Expand Down
52 changes: 46 additions & 6 deletions queries/php_only/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
(qualified_name
(name) @type
)
; crates.io skip
(relative_name
(name) @type
)
]
)

Expand All @@ -223,6 +227,10 @@
(qualified_name
(name) @type
)
; crates.io skip
(relative_name
(name) @type
)
]
)

Expand Down Expand Up @@ -306,6 +314,10 @@
(qualified_name
(name) @type
)
; crates.io skip
(relative_name
(name) @type
)
]
)

Expand All @@ -315,6 +327,10 @@
(qualified_name
(name) @type
)
; crates.io skip
(relative_name
(name) @type
)
]
)

Expand All @@ -325,6 +341,10 @@
(qualified_name
(name) @type
)
; crates.io skip
(relative_name
(name) @type
)
]
(name) @constant
)
Expand All @@ -335,6 +355,10 @@
(qualified_name
(name) @type
)
; crates.io skip
(relative_name
(name) @type
)
]
)

Expand All @@ -358,6 +382,10 @@
(qualified_name
(name) @type
)
; crates.io skip
(relative_name
(name) @type
)
]
)

Expand All @@ -380,13 +408,16 @@
)

(function_call_expression
function: (qualified_name
function: [
(name) @function.call
)
)

(function_call_expression
(name) @function.call
(qualified_name
(name) @function.call
)
; crates.io skip
(relative_name
(name) @function.call
)
]
)

(scoped_call_expression
Expand Down Expand Up @@ -432,6 +463,10 @@
(qualified_name
(name) @constructor
)
; crates.io skip
(relative_name
(name) @constructor
)
]
)

Expand Down Expand Up @@ -493,6 +528,11 @@
(name) @module
)

; crates.io skip
(relative_name
"namespace" @module.builtin
)

; Attributes
(attribute_list) @attribute

Expand Down
12 changes: 6 additions & 6 deletions queries/rush/locals.scm
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
;; Forked from https://github.com/rush-rs/tree-sitter-rush/blob/main/queries/rush/locals.scm
;; Licensed under the MIT license
(block) @scope
(block) @local.scope

; Functions
(function_definition
name: (ident) @definition.function
name: (ident) @local.definition.function
)

(parameter
name: (ident) @definition.parameter
name: (ident) @local.definition.parameter
)

; Variables
(let_stmt
name: (ident) @definition.var
name: (ident) @local.definition.var
)

(for_stmt
name: (ident) @definition.var
name: (ident) @local.definition.var
)

; References
(ident) @reference
(ident) @local.reference
5 changes: 0 additions & 5 deletions queries/rust/locals.scm
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
name: (type_identifier) @local.definition.type
)

(constrained_type_parameter
left: (type_identifier) @local.definition.type
)

; the P in remove_file<P: AsRef<Path>>(path: P)
(enum_item
name: (type_identifier) @local.definition.type
)
Expand Down
4 changes: 4 additions & 0 deletions queries/typescript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@
name: (_) @function.method
)

(abstract_method_signature
name: (property_identifier) @function.method
)

; property signatures
(property_signature
name: (property_identifier) @function.method
Expand Down
26 changes: 26 additions & 0 deletions queries/yaml/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,29 @@
"---"
"..."
] @punctuation.special

; help deal with for yaml's norway problem https://www.bram.us/2022/01/11/yaml-the-norway-problem/
; only using `true` and `false`, since Treesitter parser targets YAML spec 1.2 https://github.com/nvim-treesitter/nvim-treesitter/pull/7512#issuecomment-2565397302
(block_mapping_pair
value: (block_node
(block_sequence
(block_sequence_item
(flow_node
(plain_scalar
(string_scalar) @boolean
(#any-of? @boolean "TRUE" "FALSE" "True" "False")
)
)
)
)
)
)

(block_mapping_pair
value: (flow_node
(plain_scalar
(string_scalar) @boolean
(#any-of? @boolean "TRUE" "FALSE" "True" "False")
)
)
)
20 changes: 11 additions & 9 deletions syntastica-macros/languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ name = "c"
group = "some"
file-types = ["c"]
[languages.parser]
git = { url = "https://github.com/tree-sitter/tree-sitter-c", rev = "cf36b0354a2d75a42f87191cbd3166ad8af348e4" }
git = { url = "https://github.com/tree-sitter/tree-sitter-c", rev = "2a265d69a4caf57108a73ad2ed1e6922dd2f998c" }
external-scanner = { c = false, cpp = false }
ffi-func = "tree_sitter_c"
rust-const = "LANGUAGE"
Expand All @@ -51,7 +51,7 @@ name = "c_sharp"
group = "most"
file-types = ["csharp"]
[languages.parser]
git = { url = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "b27b091bfdc5f16d0ef76421ea5609c82a57dff0" }
git = { url = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "b5eb5742f6a7e9438bee22ce8026d6b927be2cd7" }
external-scanner = { c = true, cpp = false }
ffi-func = "tree_sitter_c_sharp"
rust-const = "LANGUAGE"
Expand Down Expand Up @@ -356,7 +356,7 @@ name = "julia"
group = "all"
file-types = ["julia"]
[languages.parser]
git = { url = "https://github.com/tree-sitter/tree-sitter-julia", rev = "3f9870ca1f419e480f39fc181fcfb6dad480969a" }
git = { url = "https://github.com/tree-sitter/tree-sitter-julia", rev = "12a3aede757bc7fbdfb1909507c7a6fddd31df37" }
external-scanner = { c = true, cpp = false }
ffi-func = "tree_sitter_julia"
rust-const = "LANGUAGE"
Expand All @@ -377,6 +377,7 @@ external-scanner = { c = true, cpp = false }
ffi-func = "tree_sitter_latex"
# rust-const = "LANGUAGE"
package = "tree-sitter-latex"
# there is a package called "tree-sitter-latex" on crates.io, but that is a different latex parser
# crates-io = ""
generate = true
[languages.queries]
Expand Down Expand Up @@ -486,7 +487,7 @@ name = "php"
group = "most"
file-types = ["php"]
[languages.parser]
git = { url = "https://github.com/tree-sitter/tree-sitter-php", rev = "f3a19ab3217a6e838870fc7142fa492d1fd7a7c9", path = "php" }
git = { url = "https://github.com/tree-sitter/tree-sitter-php", rev = "f7cf7348737d8cff1b13407a0bfedce02ee7b046", path = "php" }
external-scanner = { c = true, cpp = false }
ffi-func = "tree_sitter_php"
rust-const = "LANGUAGE_PHP"
Expand Down Expand Up @@ -566,12 +567,12 @@ name = "rush"
group = "all"
file-types = ["rush"]
[languages.parser]
git = { url = "https://github.com/rush-rs/tree-sitter-rush", rev = "20c04a0824dabcbf8119a84979cfb1c6f6c2155f" }
git = { url = "https://github.com/rush-rs/tree-sitter-rush", rev = "babbc5c116ce964e89bc9ccc9df36d16c623fba9" }
external-scanner = { c = false, cpp = false }
ffi-func = "tree_sitter_rush"
# rust-const = "LANGUAGE"
rust-const = "LANGUAGE"
package = "tree-sitter-rush"
# crates-io = "0.1.0"
crates-io = "0.2.0"
[languages.queries]
nvim-like = true
injections = false
Expand All @@ -582,7 +583,7 @@ name = "rust"
group = "some"
file-types = ["rust"]
[languages.parser]
git = { url = "https://github.com/tree-sitter/tree-sitter-rust", rev = "2eaf126458a4d6a69401089b6ba78c5e5d6c1ced" }
git = { url = "https://github.com/tree-sitter/tree-sitter-rust", rev = "6e883a2adea9414799300699e78c0d2f032b5c46" }
external-scanner = { c = true, cpp = false }
ffi-func = "tree_sitter_rust"
rust-const = "LANGUAGE"
Expand Down Expand Up @@ -694,11 +695,12 @@ name = "verilog"
group = "all"
file-types = ["verilog"]
[languages.parser]
git = { url = "https://github.com/gmlarumbe/tree-sitter-systemverilog", rev = "15fbf73dafaffc89050d247857beb27500ea30e8" }
git = { url = "https://github.com/gmlarumbe/tree-sitter-systemverilog", rev = "3251f8cee388314ed425c5e5da2021113f0b6afb" }
external-scanner = { c = false, cpp = false }
ffi-func = "tree_sitter_verilog"
rust-const = "LANGUAGE"
package = "tree-sitter-verilog"
# there is a package called "tree-sitter-verilog" on crates.io, but that is a different verilog parser
# crates-io = ""
[languages.queries]
nvim-like = true
Expand Down
5 changes: 3 additions & 2 deletions syntastica-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn parsers_rust(crate_name: &str, crates_io: bool, query_suffix: &str) -> TokenS
let name = format_ident!("{}", lang.name);
let name_str = &lang.name;
let (doc, body) = match &lang.parser.rust_const {
Some(ident) if (!crates_io && !lang.parser.generate) || lang.parser.crates_io.is_some() => {
Some(ident) if (!crates_io && !lang.parser.generate) || (crates_io && lang.parser.crates_io.is_some()) => {
let ident = format_ident!("{ident}");
let package = format_ident!("{}", lang.parser.package.replace('-', "_"));
(
Expand Down Expand Up @@ -161,7 +161,8 @@ fn parsers_rust(crate_name: &str, crates_io: bool, query_suffix: &str) -> TokenS
functions,
|lang| {
lang.parser.rust_const.is_some()
&& ((!crates_io && !lang.parser.generate) || lang.parser.crates_io.is_some())
&& ((!crates_io && !lang.parser.generate)
|| (crates_io && lang.parser.crates_io.is_some()))
},
None,
query_suffix,
Expand Down
Loading

0 comments on commit 77fbf5f

Please sign in to comment.