From ec27d0707a2b0fb39ad602060094b4e2994f988f Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 17 Feb 2024 09:19:24 -0500 Subject: [PATCH] Highlight Rust doc comments with markdown The test changes are needed because of the changes to comment parsing. The `1..36` to `1..37` change is because line comments now consume the newline. --- helix-core/src/syntax.rs | 8 ++++---- languages.toml | 2 +- runtime/queries/rust/highlights.scm | 2 +- runtime/queries/rust/injections.scm | 6 +++++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index a9344448f..4f14ed225 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -2687,10 +2687,10 @@ mod test { ) }; - test("quantified_nodes", 1..36); + test("quantified_nodes", 1..37); // NOTE: Enable after implementing proper node group capturing - // test("quantified_nodes_grouped", 1..36); - // test("multiple_nodes_grouped", 1..36); + // test("quantified_nodes_grouped", 1..37); + // test("multiple_nodes_grouped", 1..37); } #[test] @@ -2861,7 +2861,7 @@ mod test { #[test] fn test_pretty_print() { - let source = r#"/// Hello"#; + let source = r#"// Hello"#; assert_pretty_print("rust", source, "(line_comment)", 0, source.len()); // A large tree should be indented with fields: diff --git a/languages.toml b/languages.toml index b158606b0..246b48a3c 100644 --- a/languages.toml +++ b/languages.toml @@ -234,7 +234,7 @@ args = { attachCommands = [ "platform select remote-gdb-server", "platform conne [[grammar]] name = "rust" -source = { git = "https://github.com/tree-sitter/tree-sitter-rust", rev = "0431a2c60828731f27491ee9fdefe25e250ce9c9" } +source = { git = "https://github.com/tree-sitter/tree-sitter-rust", rev = "35f4a5b8a29c161402e89dba83dcdc9876ba1dac" } [[language]] name = "sway" diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm index 3cda9d520..fb10cea0e 100644 --- a/runtime/queries/rust/highlights.scm +++ b/runtime/queries/rust/highlights.scm @@ -51,7 +51,7 @@ (lifetime "'" @label (identifier) @label) -(loop_label +(label "'" @label (identifier) @label) diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm index b05b9d975..06c4d13af 100644 --- a/runtime/queries/rust/injections.scm +++ b/runtime/queries/rust/injections.scm @@ -1,6 +1,10 @@ -([(line_comment) (block_comment)] @injection.content +([(line_comment !doc) (block_comment !doc)] @injection.content (#set! injection.language "comment")) +((doc_comment) @injection.content + (#set! injection.language "markdown") + (#set! injection.combined)) + ((macro_invocation macro: [