[WIP] Implement a scrollbar highlighter#2597
Conversation
Small thought. While this is kind of true, and scrollbar is cool feature, I've never though that positioning in a file means anything really. I've liked that in Emacs with powerline you can have like a mini-map in the statusline, that shows position in the file, but never found it really useful. Unless I'm comparing files with diff, and I need to see if there's more to see below. That's why I've made a By the way sublime text style minimap is way more informative compared to scrollbar, but I understand that we can't do such thing in TUI. So percent position in a file usually enough for me in most cases
That's actually a great feature in such editors as VS Code, and IIRC Intellij Idea. If we could utilize it with language server, or builtin linters this actually will make whole life easier, but I see a small problem here. Since such scrollbar is limited in "resolution" to terminal height, and one char width, we can't display such marks with precision. For really long files this would mean that seeing error mark on a scrollbar isn't correspond with actual positon of the mark, since limited resolution of scrollbar would include hundreds of lines in one vertical character. Tha'ts not a problem for GUI, since we can create scrollbar of any pixel height, and display marks on it with pixel precision, but that's not the case for TUI. So I feel like this feature is questionable, and may lead to inconsistency of movement within the file for newcomers. |
|
Thanks for the feedback.
If you checkout the branch, you can try it on lint flags or lsp errors, it reuses the same options. You're right that the lack of resolution is a concern, I think I need to test the PR on "real" usecases. It might be possible to double the resolution by using half-blocks with different foreground/background, but that would hard-code the characters, which I don't think is worth it. |
|
Do you know if it would be feasible to make the scroll bar something like Oni did? That is to have a small line within the view block to indicate the cursor position in the view. This, of course, wouldn't be necessary. But it would be cool. |
|
It would be possible but we would have to hardcode the characters used for the scrollbar. Currently they are configurable and by default use the same characters as the completion scrollbar, which has this nice dithered pattern for the "background". |
wait, so I can configure those scrollbar symbols? |
|
Not the ones that already exist (completions, prompt suggestions), only the one from this PR's highlighter. |
It's also a lot more expensive in terms of screen real estate. It effectively prohibits a two-pane vertical spilt on a portrait oriented window, and the additional information a minimap provides is worth very little by comparison imho. A scroll bar does not have this drawback. |
It can be quite tricky to know if the buffer will fit the view, so until this can be done reliably, show it always.
|
For anyone wanting a scrollbar that works with official Kakoune builds, there's a scrollbar plugin at https://github.com/sawdust-and-diamonds/scrollbar.kak |
This highlighter adds a scrollbar that visualizes the position of the view within the buffer. I find it useful because we currently don't have a way to get a sense of how big a buffer is, nor where we are relatively.
It also allows adding 'indicator' sub-highlighters that can be used to modify the color of portions of the scrollbar. This is currently done via
line-specsoptions because the main use-case I can think of is to get a rough idea of where you have {errors,warnings,diff,breakpoints,...} in a buffer. But it would be easy to change it to anint-listthat simply specify the lines.Multiple 'indicators' can be added, in which case they will compete for setting the face of the scrollbar cell. The first indicator added has precedence.
This can be tested like so:
(on a buffer that has diff, in order to see the colors changing).
Issues
context.setup.window_range. It also means it suffers from the same issue described in Wrap highlighter with -marker shifts columns #2594