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

Add total line info to statusline #649

Closed
wants to merge 1 commit into from
Closed

Conversation

fplust
Copy link

@fplust fplust commented Aug 24, 2021

No description provided.

Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to see these by default but instead associate it with a key. Like g ^g will show Col 1 of 126; Line 2 of 97; Word 2 of 639; Byte 11 of 4373.

@archseer
Copy link
Member

Hmm, this is going to get tricky because everyone is used to a different statusline format. (I personally don't want any of these new values shown).

I'd like to keep the default statusline as is, but I would accept a PR that makes this field configurable with a format string: {line}:{col} {total} {percent}% for example. Before rendering the field you can then simply .replace("{line}", line_num) etc.

@kirawi
Copy link
Member

kirawi commented Aug 27, 2021

Hmm, this is going to get tricky because everyone is used to a different statusline format. (I personally don't want any of these new values shown).

I'd like to keep the default statusline as is, but I would accept a PR that makes this field configurable with a format string: {line}:{col} {total} {percent}% for example. Before rendering the field you can then simply .replace("{line}", line_num) etc.

Templating should work, e.g. https://docs.rs/indicatif/0.16.2/indicatif/index.html#templates

@archseer
Copy link
Member

Yeah that's what I mean by a format string. Sadly we can't use format!("{value}", value=4); etc since it has to be a static string, but doing it manually via substitutions should work just as fine.

@kirawi
Copy link
Member

kirawi commented Aug 27, 2021

Yeah that's what I mean by a format string. Sadly we can't use format!("{value}", value=4); etc since it has to be a static string, but doing it manually via substitutions should work just as fine.

I think indicatif parses the string for any {}, so I wonder if we could just copy paste that.

@archseer
Copy link
Member

It uses a regex to parse the template, then substitutes a fixed set of keys. https://github.com/mitsuhiko/indicatif/blob/27c8cc3078b65aa2573dbe673a00471d6662698c/src/style.rs#L238-L390

@archseer
Copy link
Member

We might be able to reuse that with some tweaking (lazy_static -> once_cell, disabling styles for now)

@pickfire
Copy link
Contributor

pickfire commented Sep 1, 2021

We might want a temporary solution here until we support plugin.

@archseer
Copy link
Member

Closing in favour of #2434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-discussion Status: Needs discussion or design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants