-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lsp): configurable diagnostic severity #1325
Changes from 3 commits
fbbc92a
e30e3eb
4e4ddad
73529dd
40516d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,6 +378,7 @@ impl Application { | |
let doc = self.editor.document_by_path_mut(&path); | ||
|
||
if let Some(doc) = doc { | ||
let lang_conf = doc.language_config(); | ||
let text = doc.text(); | ||
|
||
let diagnostics = params | ||
|
@@ -415,19 +416,28 @@ impl Application { | |
return None; | ||
}; | ||
|
||
let severity = | ||
diagnostic.severity.map(|severity| match severity { | ||
DiagnosticSeverity::ERROR => Error, | ||
DiagnosticSeverity::WARNING => Warning, | ||
DiagnosticSeverity::INFORMATION => Info, | ||
DiagnosticSeverity::HINT => Hint, | ||
severity => unimplemented!("{:?}", severity), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this just return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not going to change (at least in foreseeable future). I changed the statement to |
||
}); | ||
|
||
if let Some(lang_conf) = lang_conf { | ||
if let Some(severity) = severity { | ||
if severity < lang_conf.diagnostic_severity { | ||
return None; | ||
} | ||
} | ||
}; | ||
|
||
Some(Diagnostic { | ||
range: Range { start, end }, | ||
line: diagnostic.range.start.line as usize, | ||
message: diagnostic.message, | ||
severity: diagnostic.severity.map( | ||
|severity| match severity { | ||
DiagnosticSeverity::ERROR => Error, | ||
DiagnosticSeverity::WARNING => Warning, | ||
DiagnosticSeverity::INFORMATION => Info, | ||
DiagnosticSeverity::HINT => Hint, | ||
severity => unimplemented!("{:?}", severity), | ||
}, | ||
), | ||
severity, | ||
// code | ||
// source | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new entry, the rest is just formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diagnostic-severity
, we remap the name to kebab-case via serdeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, forgot, fixed now