Skip to content

Commit

Permalink
Merge branch 'inline-diagnostics' of github.com:pascalkuthe/helix
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Apr 2, 2024
2 parents bfbb210 + e86b778 commit 22bec41
Show file tree
Hide file tree
Showing 25 changed files with 1,616 additions and 495 deletions.
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ The following statusline elements can be configured:
| `display-signature-help-docs` | Display docs under signature help popup | `true` |
| `snippets` | Enables snippet completions. Requires a server restart (`:lsp-restart`) to take effect after `:config-reload`/`:set`. | `true` |
| `goto-reference-include-declaration` | Include declaration in the goto references popup. | `true` |
| `display-inline-diagnostics` | Display diagnostics under their starting line | `true` |

[^1]: By default, a progress spinner is shown in the statusline beside the file path.

Expand Down
1 change: 1 addition & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ These scopes are used for theming the editor interface:
| `ui.text.inactive` | Same as `ui.text` but when the text is inactive (e.g. suggestions) |
| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) |
| `ui.virtual.diagnostics` | Default style for inline diagnostics lines (notably control the background) |
| `ui.virtual.whitespace` | Visible whitespace characters |
| `ui.virtual.indent-guide` | Vertical indent width guides |
| `ui.virtual.inlay-hint` | Default style for inlay hints of all kinds |
Expand Down
16 changes: 15 additions & 1 deletion helix-core/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
use serde::{Deserialize, Serialize};

/// Describes the severity level of a [`Diagnostic`].
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Deserialize, Serialize)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Severity {
Hint,
Info,
Expand All @@ -23,6 +24,12 @@ pub struct Range {
pub end: usize,
}

impl Range {
pub fn contains(self, pos: usize) -> bool {
(self.start..self.end).contains(&pos)
}
}

#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
pub enum NumberOrString {
Number(i32),
Expand Down Expand Up @@ -52,3 +59,10 @@ pub struct Diagnostic {
pub source: Option<String>,
pub data: Option<serde_json::Value>,
}

impl Diagnostic {
#[inline]
pub fn severity(&self) -> Severity {
self.severity.unwrap_or(Severity::Warning)
}
}
Loading

0 comments on commit 22bec41

Please sign in to comment.