Commit Graph

98 Commits (e284038e075004e892ae66b2f98a69abaeb9e60b)

Author SHA1 Message Date
Nik Revenco e284038e07
Merge a2f219968a into 4281228da3 2025-07-24 23:36:27 +01:00
Michael Davis 63eb1b870c
Add initial tags.scm queries
Co-authored-by: cgahr <26804763+cgahr@users.noreply.github.com>
Co-authored-by: eh <correia.eh@gmail.com>
2025-07-18 11:12:41 -04:00
Nik Revenco a2f219968a queries: Highlight mutable variables in Rust 2025-07-14 02:28:50 +01:00
Nik Revenco e610e7dd80 queries: Highlight interpolations in the `rsx!` macro 2025-07-14 02:02:12 +01:00
Nik Revenco b273b89249 Merge branch 'master' into rust-better-fns 2025-07-14 02:00:34 +01:00
Michael Davis 86f10ae24c
Add a language to fix Rust highlights in format-args macros
This is a bit hacky. Injections cannot stack on each other like
highlights because layers can have their own injections. So this new
language `rust-format-args-macro` emulates that. It unconditionally
injects `rust-format-args` into all strings. Rust injects this new
language into known format-args macros like `println!`.

The downside is that this can cause false-positive highlights within
these macros for strings which happen to contain format-args syntax

    println!("Hello, {}!", "{}");
    //               ^ format args syntax
    //                      ^ not format args syntax, but highlighted
    //                        as if it were :(

This false-positive case is expected to be rare.

Injecting this fake language fixes regular non-string highlights in
macro invocations: macro invocations need to inject the entire token
tree and use `injection.include-children` for proper highlighting.
2025-07-13 12:01:18 -04:00
Nik Revenco df1ea8cba3 queries: do not highlight `bar` in `bar = || ()` as closure 2025-07-12 15:42:34 +01:00
Nik Revenco db15411f63 queries: highlight more patterns in parameters 2025-07-12 15:09:41 +01:00
Nik Revenco 6ddadd3fa7 queries: highlight local closures 2025-07-12 14:35:13 +01:00
Nik Revenco 36c4fa6ab4 fix: `map_or_else` has both arguments as closures 2025-07-12 14:24:38 +01:00
Nik Revenco 9de1c7213b queries: `bar` in `let bar = || 4` is a function 2025-07-12 14:18:12 +01:00
Nik Revenco b5a07f9974 queries: `bar` in `foo::bar` is always a function when passed as arg 2025-07-12 14:11:22 +01:00
Nik Revenco 42db29a32d fix: highlight `_` in `[_]` as `@comment.unused` 2025-07-11 03:21:45 +01:00
Nik Revenco fd11bd26cb queries: improve `@function` highlights when passed as arguments 2025-07-11 03:16:35 +01:00
CalebLarsen 60fce357fb
queries: Fix Rust function parameter locals tracking (#13828) 2025-06-24 08:08:25 -05:00
Caleb Larsen ae3eac8aeb fix: Rust now correctly highlights doc comments as @comment.{block,line}.documentation instead of @comment 2025-06-10 10:54:05 -04:00
Nik Revenco 2baff46b25
fix: Some Incorrect Rust highlights (#13657)
Co-authored-by: Nik Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-05-31 09:43:19 -05:00
Nik Revenco 1023e8f964
feat: highlight rust string interpolation macros that use `format_args!` (#13533)
Co-authored-by: Nik Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-05-24 10:02:32 -05:00
Michael Davis 05ae617e1c
queries: Reorder Slint and HTML injections in Rust
This fixes injections of Slint and HTML in Rust macros. These patterns
must be moved after the generic `(macro_invocation (token_tree))`
pattern since they are more specific, and later patterns now take
priority.

See <https://redirect.github.com/helix-editor/helix/pull/12972#issuecomment-2888300442>.
2025-05-17 08:48:01 -04:00
Michael Davis f46222ced3
Revert "feat: Highlight Rust String interpolation macros"
This reverts commit 9bb80a74e1.
2025-05-13 19:52:48 -04:00
Nikita Revenco 9bb80a74e1
feat: Highlight Rust String interpolation macros
Fixes #5845
2025-05-13 19:31:42 -04:00
Michael Davis be1cf090c3
queries: Inject markdown into Rust doc comments
Co-authored-by: Nik Revenco <154856872+nik-rev@users.noreply.github.com>
2025-05-13 19:01:10 -04:00
Michael Davis a3b64b6da2
queries: Rewrite all locals 2025-05-13 19:01:10 -04:00
Michael Davis 1bd7a3901c
queries: Add JSON injection for Rust `json!({..})` macros
Note that this injection doesn't work currently because precedence is
not handled by the current syntax highlighter. The switch to tree-house
will properly handle the precedence of this pattern.
2025-03-12 17:46:17 -04:00
may 694b61514f
queries: Inject into string content in Rust injections
This change also recognizes `RegexBuilder::new` calls for the regex
injection.
2025-03-12 17:31:50 -04:00
Nik Revenco ef375d690e
feat: highlight rust repetition pattern (#12871)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-02-17 12:54:49 -06:00
Nikita Revenco 1b89f998e8
fix: Rust highlights (regression from the reverse-query-precedence PR) (#12795)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-02-07 08:51:22 -06:00
Viktor Szépe e22bbf5489
Fix typos (#12690) 2025-02-02 18:58:29 -06:00
Michael Davis b8bfc44e42
queries: Improve Rust const generic and '_' type highlighting
You may pass constants as type arguments the const generics feature.
This is used in spellbook for example as a poor man's enum, for example
`self.strip_suffix_only::<FULL_WORD>(word, hidden_homonym)`. With this
change that `FULL_WORD` part is highlighted as a constant instead of
a type.

This change also highlight the underscore in type placeholders - this
is similar to the highlighting done for bindings in Elixir or Erlang
for example. In `Vec<_>` the underscore is highlighted the same as a
comment.
2025-02-02 19:28:01 -05:00
Michael Davis 5952d564d1
Reverse highlight precedence ordering (#9458)
Co-authored-by: postsolar <120750161+postsolar@users.noreply.github.com>
Co-authored-by: Iorvethe <58810330+Iorvethe@users.noreply.github.com>
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: gabydd <gabydinnerdavid@gmail.com>
2025-02-02 18:17:10 -06:00
Michael Davis 1afa63d457
rust: Highlight `/` and `!` within comments as comments 2025-01-23 16:17:44 -05:00
Rock Boynton dca235c5c8
Update `tree-sitter-rust` (#12607)
Co-authored-by: Rock Boynton <rboynton@anduril.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-01-23 13:11:07 -06:00
Nikita Revenco a539199666
feat(highlights): add more built-in functions for `ecma`, `rust` and `haskell` (#12488)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-01-11 14:59:03 -06:00
Nikita Revenco 8f5f818c88
fix(highlights): recognize `!` as the never type (#12485)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-01-11 10:49:39 -06:00
Nikita Revenco eed052e86b
feat: highlight `:` as a delimiter in Rust (#12408) 2025-01-05 10:51:33 -06:00
Frans Skarman f9aae99379
Highlight types and enum members in the rust prelude (#8535)
* Add some rust builtins

* rust queries: Add everything in the 2021 prelude

* Update runtime/queries/rust/highlights.scm

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2024-08-14 19:43:31 +02:00
Luv-Ray 752ed8eb15
add `try` keyword to rust highlights (#10641) 2024-04-30 13:13:27 +09:00
Pedro Fedricci 0546273570
chore: update tree-sitter-rust to v0.21.0 (#10365)
* chore: update tree-sitter-rust to 0.21.0

* fix: pretty print and textobject tests
2024-04-15 18:07:15 +02:00
Daniel S Poulin 1abb64e48d
Add textobject for entries/elements of list-like things (#8150) 2024-03-31 11:53:15 -05:00
Michael Davis c099dde2a7 Rust: Highlight extern crate aliases
For example `extern crate alloc as myalloc;`
2024-03-22 00:20:29 +09:00
Vivek Kethineni 3e963b3c1b
Add Rust fields as argument textobject (#9637)
* added field_declaration_list and field_initializer_list as parameter textobjects

* removed field_declaration_listt from textobjects.scm
2024-02-17 17:08:44 +01:00
Tobias Hunger a1272bdb17
slint: Update treesitter parser and queries (#9551)
* slint: Update treesitter parser and queries

* slint: Port over suggestions from nvim review
2024-02-07 19:36:29 +01:00
Rose Hudson a680b2e409
rust highlights: clean up constructor logic (#8957)
Enum variants and (tuple) structs are indistinguishable in general, so we
mark any PascalCase pattern or expression as a "constructor", which
covers all three.
2024-01-02 16:38:13 +01:00
Joey Hain 70bbbd7d19
add highlight scope for type parameters (#8660)
* rust: add highlight scope for type parameters

* handle optional type parameters
2023-11-03 22:21:01 +01:00
Ryan Mehri c24a67c0e4
Add rust html injection query (#8603) 2023-10-26 11:39:22 +09:00
Jesse Luehrs d56638ba9a fix formatting in the rust textobject query file
looks like two lines were unintentionally joined - it doesn't appear to
affect the functionality, but it's confusing to read
2023-08-14 07:45:58 -04:00
Daniel Ebert 36a59e4482 Improve C, Rust & Python indent queries & add @align captures. 2023-08-11 23:44:02 +09:00
Cole Helbling 6dd5054da4
Highlight sqlx's `query_scalar{,_unchecked}` macros as SQL (#6793)
* Highlight sqlx's `query_scalar{,_unchecked}` macros as SQL

* Update injections.scm

* fixup copy-pasta
2023-04-27 14:37:17 +09:00
Maxicarlos08 3d230e701d
Also highlight unchecked variants of the sqlx query methods (#6256) 2023-03-10 16:57:52 -06:00
Chickenkeeper 486c3ab0d5
Fix Broken Attribute Highlights (#5349)
* Update highlights.scm

* Update highlights.scm

* Update themes.md
2023-01-09 11:26:08 +09:00