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

(v2) Line Number Gutterfunc Adjustments #738

Open
meowgorithm opened this issue Feb 18, 2025 · 4 comments
Open

(v2) Line Number Gutterfunc Adjustments #738

meowgorithm opened this issue Feb 18, 2025 · 4 comments
Assignees

Comments

@meowgorithm
Copy link
Member

Ideally, we'll want to be able to style the bar differently than the line numbers in this guy:

// LineNumberGutter return a [GutterFunc] that shows line numbers.
func LineNumberGutter(style lipgloss.Style) GutterFunc {
	return func(info GutterContext) string {
		if info.Soft {
			return style.Render("     │ ")
		}
		if info.Index >= info.TotalLines {
			return style.Render("   ~ │ ")
		}
		return style.Render(fmt.Sprintf("%4d │ ", info.Index+1))
	}
}

On that note we should also add a func that is just line numbers with no bar.

@caarlos0
Copy link
Member

i mean, yes, the default one should probably be simpler, and leave specifics to the caller

@meowgorithm
Copy link
Member Author

I this one is so nice though, could keep it in as a bonus with two args.

@caarlos0
Copy link
Member

yeah, looking at it now, i think it would break if lineno > 9999 though

@meowgorithm
Copy link
Member Author

Ah, indeed. In general, it might be good to get either the max lines, or maybe better yet, the model as an arg for more context and set widths accordingly.

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

No branches or pull requests

2 participants