Skip to content

fix use markup for diagnostics in lsp to codify backtics #1177#2352

Closed
asukaminato0721 wants to merge 5 commits intofacebook:mainfrom
asukaminato0721:1177
Closed

fix use markup for diagnostics in lsp to codify backtics #1177#2352
asukaminato0721 wants to merge 5 commits intofacebook:mainfrom
asukaminato0721:1177

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

@asukaminato0721 asukaminato0721 commented Feb 7, 2026

Summary

Fixes #1177

Added detection of markupMessageSupport from client capabilities and emit markdown-formatted diagnostic messages for both textDocument/publishDiagnostics and textDocument/diagnostic when supported.

Threaded the capability through initialization and server construction.

Test Plan

added an LSP interaction test covering markdown diagnostics.

@github-actions

This comment has been minimized.

@asukaminato0721 asukaminato0721 marked this pull request as ready for review February 7, 2026 04:24
Copilot AI review requested due to automatic review settings February 7, 2026 04:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds LSP 3.18-style markup support for diagnostic messages so clients can render diagnostic text as Markdown (e.g., backticks as code spans), and updates initialization plumbing to propagate this capability through both LSP and TSP entrypoints.

Changes:

  • Introduce InitializeInfo to carry InitializeParams plus a supports_diagnostic_markdown flag derived from client capabilities.
  • When supported, wrap Diagnostic.message strings into { kind: "markdown", value: ... } for both publishDiagnostics and textDocument/diagnostic responses.
  • Add a regression test that opts into markup support and asserts Markdown-shaped diagnostic messages.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyrefly/lib/lsp/non_wasm/server.rs Detect markup support at initialize time; conditionally rewrite diagnostic JSON to MarkupContent for push/pull diagnostics.
pyrefly/lib/test/lsp/lsp_interaction/diagnostic.rs Add test verifying Markdown-shaped diagnostics when capability is enabled.
pyrefly/lib/commands/lsp.rs Thread InitializeInfo through LSP startup instead of bare InitializeParams.
pyrefly/lib/commands/tsp.rs Thread InitializeInfo through TSP startup and into Server::new.
pyrefly/lib/tsp/server.rs Update tsp_loop signature to accept the new initialization wrapper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyrefly/lib/lsp/non_wasm/server.rs Outdated
Comment on lines +74 to +79
interaction
.client
.expect_any_message()
.expect("Failed to receive configuration request");
interaction.client.send_response::<WorkspaceConfiguration>(
RequestId::from(1),
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test hard-codes the request id RequestId::from(1) for the server’s workspace/configuration request and uses expect_any_message() instead of asserting the request type/id. This is brittle if the server sends any other request first (or changes its outgoing request id sequence). Prefer expect_configuration_request(...) / expect_request::<WorkspaceConfiguration>(...) to capture the actual id and respond to the correct request.

Suggested change
interaction
.client
.expect_any_message()
.expect("Failed to receive configuration request");
interaction.client.send_response::<WorkspaceConfiguration>(
RequestId::from(1),
let request_id = interaction
.client
.expect_configuration_request()
.expect("Failed to receive configuration request");
interaction.client.send_response::<WorkspaceConfiguration>(
request_id,

Copilot uses AI. Check for mistakes.
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Feb 9, 2026

@jvansch1 has imported this pull request. If you are a Meta employee, you can view this in D92713211.

Comment thread pyrefly/lib/lsp/non_wasm/server.rs
Comment thread pyrefly/lib/lsp/non_wasm/server.rs Outdated
@github-actions

This comment has been minimized.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Copy Markdown
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Feb 25, 2026

@jvansch1 merged this pull request in 6742340.

@asukaminato0721 asukaminato0721 deleted the 1177 branch February 26, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use markup for diagnostics in lsp to codify backtics

5 participants