Skip to content

Markdown code block syntax highlighting issues in Quick Documentation #557

Closed

Description

@angelozerr

Discussed in #492

Originally posted by harry-xm August 28, 2024
// is not grayed out in the following parts of a textDocument/hover result, but is grayed out in the editor.

Screenshot

// Implements notable traits: Future<Output = ?>
pub fn with_graceful_shutdown<F>(self, signal: F) -> Graceful<I, S, F, E>
where
    F: Future<Output = ()>,
    E: NewSvcExec<IO, S::Future, S::Service, E, GracefulWatcher>,
// Make a server from the previous examples...
let server = Server::bind(&([127, 0, 0, 1], 3000).into())
    .serve(make_service);

...

LSP server's response is

[Trace - 20:07:31] Received response 'textDocument/hover - (89)' in 1ms.
Result: {
  "contents": {
    "kind": "markdown",
    "value": "\n```rust\nhyper::server::server::Server\n```\n\n```rust\n// Implements notable traits: Future\u003cOutput \u003d ?\u003e\npub fn with_graceful_shutdown\u003cF\u003e(self, signal: F) -\u003e Graceful\u003cI, S, F, E\u003e\nwhere\n    F: Future\u003cOutput \u003d ()\u003e,\n    E: NewSvcExec\u003cIO, S::Future, S::Service, E, GracefulWatcher\u003e,\n```\n\n---\n\nPrepares a server to handle graceful shutdown when the provided future\ncompletes.\n\n# Example\n\n```rust\n// Make a server from the previous examples...\nlet server \u003d Server::bind(\u0026([127, 0, 0, 1], 3000).into())\n    .serve(make_service);\n\n// Prepare some signal for when the server should start shutting down...\nlet (tx, rx) \u003d tokio::sync::oneshot::channel::\u003c()\u003e();\nlet graceful \u003d server\n    .with_graceful_shutdown(async {\n        rx.await.ok();\n    });\n\n// Await the `server` receiving the signal...\nif let Err(e) \u003d graceful.await {\n    eprintln!(\"server error: {}\", e);\n}\n\n// And later, trigger the signal by calling `tx.send(())`.\nlet _ \u003d tx.send(());\n```"
  },
  "range": {
    "start": {
      "line": 96,
      "character": 9
    },
    "end": {
      "line": 96,
      "character": 31
    }
  }
}
```</div>

Activity

  1. added
    bug
    on Oct 1, 2024
  2. lagergren commented on Nov 20, 2026

    @lagergren
    Collaborator

    @angelozerr does this still happen with 0.30.1? Code blocks in Quick Documentation are colored by the lexer of their language (LightQuickDocHighlightingHelper), so the gray // in the editor likely comes from semantic tokens. Which plugin provides the rust language in your setup?

  3. lagergren commented on Nov 22, 2026

    @lagergren
    Collaborator

    Closing, as this is fixed on main for 0.30.2:

    • The case of this issue works: in the documentation of a Rust file, the // comments of a ```rust code block are gray, as in the editor.
    • fix: color a code block of the documentation by the TextMate grammar of its own language #2086 fixed the rest: a code block whose language IntelliJ doesn't have is now colored by the TextMate grammar of its own language, not by that of the file. Before, a ```python block in the documentation of a Rust file was colored by the Rust grammar, and a ```rust block in that of a text file wasn't colored.

    Please reopen if it still happens with 0.30.2, with the plugin that gives the language of the code block in your setup.

  4. added this to the 0.30.2 milestone on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughover

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions