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
This commit is contained in:
0x5c
2022-02-22 04:31:32 -05:00
committed by GitHub
parent fe59e18e69
commit 987e409071
2 changed files with 7 additions and 1 deletions

View File

@@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{
} }
return "" 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) { func SetStatusInfoFnLua(fn string) {

View File

@@ -333,7 +333,7 @@ Here are the available options:
* `statusformatl`: format string definition for the left-justified part of the * `statusformatl`: format string definition for the left-justified part of the
statusline. Special directives should be placed inside `$()`. Special 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 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. and fill in the value of the option or the key bound to the action.