Commit Graph

83 Commits (ae3eac8aeb669581935cbe036de9993f44da512c)

Author SHA1 Message Date
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
Chickenkeeper c4263d6a56
Fix & Tweak Rust's Syntax Highlighting (#5238) 2022-12-21 17:10:45 -06:00
Blaž Hrastnik bae890d8fa
Update tree-sitter-scheme 2022-12-12 17:50:12 +09:00
Alexis (Poliorcetics) Bourget e232333d4a fix: Outdated Rust queries after TS update
Ref: 3ddebf46e6
2022-11-11 18:43:55 -06:00
Anton Romanov 07d3157273
[rust highlights] fix scoped attribute macro matching (#4659)
Without this scoped attribute macros are not matched as macros.
Eg
```
  #[path::macro]
```
2022-11-08 13:41:09 -06:00
Poliorcetics 2935e9da19
feat: Categorize Rust's keywords using more specific scopes (#4510) 2022-10-29 10:36:26 -05:00
Michael Davis 4a3b776b78
rust: Highlight function signatures as functions (#4073)
This stanza highlights functions within trait definitions. For example,
in:

    pub trait Widget {
        fn render(self, area: Rect, buf: &mut Buffer);
    }

`render` is currently highlighted as a variable. With this change it's
highlighted as a function.
2022-10-03 23:56:50 +09:00
gavincrawford 1dd1476a9e
Fix highlighting on single-character Rust consts (#3927)
Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com>
Co-authored-by: Gavin Crawford <gavincrawford@users.noreply.github.com>
2022-09-21 17:55:28 -05:00
Michael Davis 301f5d7cf7
Fix Rust attribute highlights (#3729) 2022-09-07 12:45:51 +09:00
Charles Hall b3b164f0d5
Highlight SQL in `sqlx::{query,query_as}!()` in Rust (#3647) 2022-09-02 17:26:42 -05:00
Michael Davis 03f0ef93ac Update tree-sitter-rust to latest
There don't appear to be any regressions from the updates.
Also included is a fix which highlights the "#" as in attributes
as punctuation. This was previously unhighlighted.
2022-08-31 17:46:34 +09:00
David db18206795
Fix rust text objects (#3590) 2022-08-28 16:03:39 -05:00
Vince Mutolo 7559b77d53
highlight closure pipes as brackets (#3397)
Co-authored-by: Vince Mutolo <vince@mutolo.org>
2022-08-11 19:00:03 -05:00
ChrHorn 23f4a40a7a
Rust queries: add `(function_item)` as a local scope (#3345) 2022-08-06 05:58:06 -05:00
Michael Davis 9ed9c3faca
Remove let_declaration from Rust locals tracking (#3212) 2022-07-28 12:04:50 +09:00
Michael Davis 9753da6ab7
Fix locals tracking in Rust closures (#3027)
The fix comes from the rewriting of the `closure_parameters` stanza:
it was capturing the entire `closure_parameters` node including
paretheses, whitespace, and commas. Capturing the identifiers within
fixes the tracking.

In order to make sure locals definitions from closure parameters don't
leak out of the body of the closure, though, we should also mark the
closure itself as a locals scope.
2022-07-20 11:51:35 +09:00