Add more functions to customize status bar

Adds `status.lines`, `status.vcol`, `status.bytes`, `status.size`,
and exposes some functions from go-humanize to plugins.

Ref #1727
This commit is contained in:
Zachary Yedidia
2020-06-24 17:19:42 -04:00
parent db1df05017
commit 5f62f550f3
5 changed files with 59 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ import (
"time"
"unicode/utf8"
humanize "github.com/dustin/go-humanize"
lua "github.com/yuin/gopher-lua"
luar "layeh.com/gopher-luar"
)
@@ -69,6 +70,8 @@ func Import(pkg string) *lua.LTable {
return importTime()
case "unicode/utf8", "utf8":
return importUtf8()
case "humanize":
return importHumanize()
default:
return nil
}
@@ -556,3 +559,14 @@ func importUtf8() *lua.LTable {
return pkg
}
func importHumanize() *lua.LTable {
pkg := L.NewTable()
L.SetField(pkg, "Bytes", luar.New(L, humanize.Bytes))
L.SetField(pkg, "Ordinal", luar.New(L, humanize.Ordinal))
L.SetField(pkg, "Ftoa", luar.New(L, humanize.Ftoa))
L.SetField(pkg, "FtoaWithDigits", luar.New(L, humanize.FtoaWithDigits))
return pkg
}