Skip to content
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

Feature request: Popup for LSP diagnostics #2553

Closed
Domerpig opened this issue May 23, 2022 · 6 comments
Closed

Feature request: Popup for LSP diagnostics #2553

Domerpig opened this issue May 23, 2022 · 6 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@Domerpig
Copy link

The LSP diagnostics in the upper right corner can sometimes be way out of my view and I have to glance back and forth between my code and the diagnostic. An option to have a popup that shows the diagnostic at the same place of the code would be nice. Or maybe showing it at the end of the line. Just somewhere closer.

@Domerpig Domerpig added the C-enhancement Category: Improvements label May 23, 2022
@kirawi
Copy link
Member

kirawi commented May 23, 2022

Related to #411

@kirawi kirawi added the A-helix-term Area: Helix term improvements label May 23, 2022
@kaleidawave
Copy link

Have found the code for rendering diagnostics, which is called by render_view (found above in the file)

pub fn render_diagnostics(
&self,
doc: &Document,
view: &View,
viewport: Rect,
surface: &mut Surface,
theme: &Theme,
) {
use helix_core::diagnostic::Severity;
use tui::{
layout::Alignment,
text::Text,
widgets::{Paragraph, Widget, Wrap},
};
let cursor = doc
.selection(view.id)
.primary()
.cursor(doc.text().slice(..));
let diagnostics = doc.diagnostics().iter().filter(|diagnostic| {
diagnostic.range.start <= cursor && diagnostic.range.end >= cursor
});
let warning = theme.get("warning");
let error = theme.get("error");
let info = theme.get("info");
let hint = theme.get("hint");
let mut lines = Vec::new();
for diagnostic in diagnostics {
let text = Text::styled(
&diagnostic.message,
match diagnostic.severity {
Some(Severity::Error) => error,
Some(Severity::Warning) | None => warning,
Some(Severity::Info) => info,
Some(Severity::Hint) => hint,
},
);
lines.extend(text.lines);
}
let paragraph = Paragraph::new(lines)
.alignment(Alignment::Right)
.wrap(Wrap { trim: true });
let width = 100.min(viewport.width);
let height = 15.min(viewport.height);
paragraph.render(
Rect::new(viewport.right() - width, viewport.y + 1, width, height),
surface,
);
}

Wondering how hard it would be to add a option to render it either under the cursor while it is highlighted or something?

@jakenvac
Copy link
Contributor

I think this falls under the same issue, but I have a slightly different grievance.

Very often imports in various languages are at the top of the file, and very often I make typos when importing stuff.

The LSP complains and then gets in the way of me fixing the issue.
image

please ignore that I'm using archaic nodeJS, some clients like it old school 😭

@poliorcetics
Copy link
Contributor

On master there is now space+g/G for file/workspace diangostic which makes the user jump to the exact position of the diagnostic, does it at least partially fix the issue ?

@pascalkuthe
Copy link
Member

I think is is a duplicate of #1953 so I am closing this issue in favor of that. If you don't think that is right and that these are two separate issues feel free to reopen.

@AddictArts
Copy link

For anyone else trying to find it, now space+d, the g is the debug experimental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

7 participants