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

Relative line numbers #483

Closed
gbaranski opened this issue Jul 21, 2021 · 9 comments · Fixed by #485
Closed

Relative line numbers #483

gbaranski opened this issue Jul 21, 2021 · 9 comments · Fixed by #485
Assignees
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@gbaranski
Copy link
Contributor

gbaranski commented Jul 21, 2021

Describe your feature request

Vim-like relative line numbers, they're very helpful for code navigation.
Screenshot_20210722-011704

this could be configured like that

line_numbers = "none" # No line numbers
line_numbers = "absolute" # Absolute line numbers(default)
line_numbers = "relative" # Relative line numbers
@gbaranski gbaranski added the C-enhancement Category: Improvements label Jul 21, 2021
@gbaranski
Copy link
Contributor Author

I can try implementing that after I'll finish #478

@Omnikar
Copy link
Contributor

Omnikar commented Jul 22, 2021

How will this work with multiple cursors?

@pickfire
Copy link
Contributor

There will still be one main cursor with multi cursors.

@pickfire pickfire added the A-helix-term Area: Helix term improvements label Jul 22, 2021
@kirawi
Copy link
Member

kirawi commented Jul 22, 2021

for (i, line) in (view.first_line..last_line).enumerate() {
use helix_core::diagnostic::Severity;
if let Some(diagnostic) = doc.diagnostics().iter().find(|d| d.line == line) {
surface.set_stringn(
viewport.x - OFFSET,
viewport.y + i as u16,
"●",
1,
match diagnostic.severity {
Some(Severity::Error) => error,
Some(Severity::Warning) | None => warning,
Some(Severity::Info) => info,
Some(Severity::Hint) => hint,
},
);
}
// line numbers having selections are rendered differently
surface.set_stringn(
viewport.x + 1 - OFFSET,
viewport.y + i as u16,
format!("{:>5}", line + 1),
5,
linenr,
);
}

This is where the line numbering is done.

@Cons-Cat
Copy link
Contributor

I hope this can be toggled while editing. In Kakoune, it is possible to make pressing 0 temporarily toggle relative line numbers until the next command executes, which is very cool.

@tryzniak
Copy link

tryzniak commented Oct 1, 2021

Hello. I didn't want to open a new issue, so I'll report here.
I think the relative numbers option is not working in the ~/.config/helix/config.toml file. But this is not working:

[editor]
line-number = "relative"

Nor line_numbers = "relative".

I'm new to Helix so maybe I'm configuring it the wrong way. Thank you

@sudormrfbin
Copy link
Member

@tryzniak Relative line numbers are only in master and not yet released, so you'll have to build from source.

@tryzniak
Copy link

tryzniak commented Oct 1, 2021

@sudormrfbin Thanks, I didn't notice that 😄

@blex-max
Copy link

Any word on this becoming something you can switch to temporarily from within helix? I'd find that very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants