evil-helix icon indicating copy to clipboard operation
evil-helix copied to clipboard

Improve display of total-line-numbers in the statusline

Open antoyo opened this issue 8 months ago • 2 comments

(I originally opened an issue upstream, but it was closed because the maintainer of Helix preferred to have this in a plugin. As such, I'm proposing it here in case you would be interested in having this feature in evil-helix: this issue suggests making the display of line numbers more similar to what we have in vim-airline.)

Hi. Currently, the display for current line and total line numbers in the statusline is separate. I'd prefer if it could be combined. For instance, to have something like this:

5/15:2

(current line)/(total line numbers):(column)

instead of:

5:2 15

I'm also open to other ideas, but I like having (current line)/(total line numbers). Thanks.

antoyo avatar May 03 '25 20:05 antoyo

I would like to implement this, so I wonder what is your opinion on this. Would you like this? If so, how would you like to see this implemented?

antoyo avatar May 14 '25 10:05 antoyo

I think increasing the configurability of the statusline is absolutely within the scope of evil-helix. I made it configurable back then, and I remember the details.

Statusline elements which we have an own implementation for (because they deviate from the upstream implementation, as is the case in this issue, or because they're new and not present in upstream) can be defined in their own functions, which in turn can be defined in evil.rs or maybe in a newly introduced evil-statusline.rs.

Regarding the integration, I'm thinking of carefully hooking into get_render_function(). Maybe store the match result in a variable, and pass that on to an evil-specific get_render_function() function (which then has the possibility to override the returned function).

I'm a little bit sceptical regarding a format string, because I'd rather have position-format configurable as a TOML list, just like the statusline elements. But I admit this complicates things with literals (colon, slash, etc.); it ends up being messy (not to mention that would probably not even deserialize correctly):

[editor.statusline]
left = ["mode", "spinner"]
center = ["file-name"]
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
position-format = ["column", {literal = ":"}, "line", {literal = "/"}, "lines_count"]

So I have no strong opinion on that. Maybe you have a good idea, otherwise we can stick to a format string.

If we do use a format string however, I would prefer that the format string is parsed only if the element is actually being used.

usagi-flow avatar May 22 '25 20:05 usagi-flow