Lua prompt support and plugin improvements

This commit is contained in:
Zachary Yedidia
2019-12-24 17:17:44 -05:00
parent 3b306c1d3b
commit 94ff79e7b2
8 changed files with 87 additions and 25 deletions

View File

@@ -68,6 +68,10 @@ func BufMapKey(k Event, action string) {
} else if strings.HasPrefix(a, "lua:") {
a = strings.SplitN(a, ":", 2)[1]
afn = LuaAction(a)
if afn == nil {
screen.TermMessage("Lua Error:", action, "does not exist")
continue
}
} else if f, ok := BufKeyActions[a]; ok {
afn = f
} else {

View File

@@ -89,11 +89,7 @@ func LuaFunctionCommand(fn string) func(*BufPane, []string) {
return nil
}
return func(bp *BufPane, args []string) {
var luaArgs []lua.LValue
luaArgs = append(luaArgs, luar.New(ulua.L, bp))
for _, v := range args {
luaArgs = append(luaArgs, luar.New(ulua.L, v))
}
luaArgs := []lua.LValue{luar.New(ulua.L, bp), luar.New(ulua.L, args)}
_, err := pl.Call(plFn, luaArgs...)
if err != nil {
screen.TermMessage(err)