Skip to content

Conversation

@archseer
Copy link
Member

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 gutters slice to loop over.

Comment on lines 442 to 451
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
Copy link
Member

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,
                    }
                })

@dannasessha
Copy link
Contributor

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 git diff type display ala the vim git gutter plugin, or a git annotate type feature to familiarize themselves with the history of a file from a certain perspective, or even possibly being able to manipulate the column directly for some kind of bespoke user-annotation that could be made on the fly.

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.

@archseer
Copy link
Member Author

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)];
Copy link
Contributor

@pickfire pickfire Nov 25, 2021

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.

Copy link
Member Author

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.

@archseer archseer marked this pull request as ready for review November 29, 2021 01:50
@archseer archseer merged commit 225e8cc into master Nov 29, 2021
@archseer archseer deleted the gutter-fn branch November 29, 2021 02:00
@archseer
Copy link
Member Author

Merging this for now, it unblocks some of my work on the debugger. We can make the gutters configurable in a follow-up

@dannasessha
Copy link
Contributor

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.

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.

5 participants