From 987e40907137323a97c94dfcdca0cbb96ab05cbc Mon Sep 17 00:00:00 2001 From: 0x5c Date: Tue, 22 Feb 2022 04:31:32 -0500 Subject: [PATCH] Added lines and percentage statusbar directives (#2055) - "lines" for the number of lines in the buffer - "percentage" for the percentage of the file at the current line Fixes zyedidia#2049 --- internal/display/statusline.go | 6 ++++++ runtime/help/options.md | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/display/statusline.go b/internal/display/statusline.go index 947a3ee7..be808eee 100644 --- a/internal/display/statusline.go +++ b/internal/display/statusline.go @@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{ } return "" }, + "lines": func(b *buffer.Buffer) string { + return strconv.Itoa(b.LinesNum()) + }, + "percentage": func(b *buffer.Buffer) string { + return strconv.Itoa((b.GetActiveCursor().Y + 1) * 100 / b.LinesNum()) + }, } func SetStatusInfoFnLua(fn string) { diff --git a/runtime/help/options.md b/runtime/help/options.md index 4d12687a..89d85396 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -333,7 +333,7 @@ Here are the available options: * `statusformatl`: format string definition for the left-justified part of the statusline. Special directives should be placed inside `$()`. Special - directives include: `filename`, `modified`, `line`, `col`, `opt`, `bind`. + directives include: `filename`, `modified`, `line`, `col`, `lines`, `percentage`, `opt`, `bind`. The `opt` and `bind` directives take either an option or an action afterward and fill in the value of the option or the key bound to the action. -- 2.44.0