-
-
Couldn't load subscription status.
- Fork 3.1k
Gutter functions #783
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
Gutter functions #783
Conversation
helix-term/src/ui/editor.rs
Outdated
| if let Some(diagnostic) = diagnostics.iter().find(|d| d.line == line) { | ||
| write!(out, "●").unwrap(); | ||
| return Some(match diagnostic.severity { | ||
| Some(Severity::Error) => error, | ||
| Some(Severity::Warning) | None => warning, | ||
| Some(Severity::Info) => info, | ||
| Some(Severity::Hint) => hint, | ||
| }, | ||
| ); | ||
| } | ||
| }); | ||
| } | ||
| None |
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.
map can simplify this:
diagnostics.iter().find(|d| d.line == line).map(|diagnostic| {
write!(out, "●").unwrap();
match diagnostic.severity {
Some(Severity::Error) => error,
Some(Severity::Warning) | None => warning,
Some(Severity::Info) => info,
Some(Severity::Hint) => hint,
}
})|
I see that some work has already gone into this feature, but I wanted to bring up the possibility of having the gutter be configurable, especially in width, as to allow for a greater number of potential uses. For example, what if a user wanted to use the column in the editor to have a It looks like line numbers and diagnostics have some level of configurability in this PR, would it be a mess to incorporate other configuration options? I think if there is a 'handle' to configurability, it might allow for greater utility for those helix users who wish to interact with such things in the future. |
|
Yeah that was the intent behind this PR, these types of gutter components give us more flexibility to allow for configuring the gutter (like disabling line numbers) or using different gutters per document (for example getting rid of diagnostics on docs with no LSP) as well as defining new types of gutters in the future (i.e. git gutter) |
| } | ||
| } | ||
|
|
||
| const GUTTERS: &[(Gutter, usize)] = &[(gutter::diagnostic, 1), (gutter::line_number, 5)]; |
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.
I think we need to somehow expose this in config, not sure if we want to do it in this patch or not.
But I am also concern whether we want to put the width here.
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.
The width is currently there so that gutters have a constant width. We will probably make them more dynamic in the future.
|
Merging this for now, it unblocks some of my work on the debugger. We can make the gutters configurable in a follow-up |
I'd be potentially interested in tackling this! I started an issue at #1188 to gather discussion and track. |
Allows us to have each gutter as a separate function so that it can be extendable in the future.
I'm not sure if this is overkill or not, I don't like the closure boxing but that was the only way to put them all on a single
guttersslice to loop over.