Skip to content

Conversation

@MatthewMckee4
Copy link

In zed, it is often quite hard to see where I have typos, since the default diagnostic type is INFORMATION. I think it is useful for users to be able to set this themselves.

Added a test to test json deserializion.

Not sure where else I can add tests.

Thanks!

Copilot AI review requested due to automatic review settings December 14, 2025 14:20
Copy link

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

This PR adds a configurable diagnosticSeverity field to the LSP initialization options, allowing users to control the severity level of spelling diagnostics. Previously, all diagnostics were hardcoded to INFORMATION level, making typos difficult to see in some editors like Zed.

Key Changes:

  • Added configurable diagnostic severity with support for "error", "warning", "information", and "hint" levels
  • Implemented custom deserializer with fallback to default when invalid values are provided
  • Updated test suite to verify JSON deserialization of the new field

Reviewed changes

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

File Description
crates/codebook-lsp/src/lsp.rs Replaced hardcoded DiagnosticSeverity::INFORMATION with configurable option from initialization settings
crates/codebook-lsp/src/init_options.rs Added diagnostic_severity field with custom deserializer, default function, and test coverage
README.md Updated example initialization options payload to include the new diagnosticSeverity field

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

Comment on lines 136 to 143
fn test_json() {
let json = r#"{"logLevel": "debug", "checkWhileTyping": false}"#;
let json =
r#"{"logLevel": "debug", "checkWhileTyping": false, "diagnosticSeverity": "warning"}"#;
let options: ClientInitializationOptions = serde_json::from_str(json).unwrap();
assert_eq!(options.log_level, LevelFilter::Debug);
assert!(!options.check_while_typing);
assert_eq!(options.diagnostic_severity, DiagnosticSeverity::WARNING);
}
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

Consider adding test cases for additional scenarios: 1) testing that invalid/unknown values fall back to the default severity (e.g., "invalid_value"), 2) testing that missing the field uses the default value, and 3) testing all four severity levels (error, warning, information, hint). This would provide more comprehensive coverage of the deserialize_diagnostic_severity function.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant