Interface with plugin.lua file

This commit is contained in:
Zachary Yedidia
2016-04-24 19:52:02 -04:00
parent 87d9221a73
commit e05e993e25
4 changed files with 37 additions and 4 deletions

View File

@@ -7,8 +7,10 @@ import (
"os"
"github.com/go-errors/errors"
"github.com/layeh/gopher-luar"
"github.com/mattn/go-isatty"
"github.com/mitchellh/go-homedir"
"github.com/yuin/gopher-lua"
"github.com/zyedidia/tcell"
"github.com/zyedidia/tcell/encoding"
)
@@ -41,6 +43,9 @@ var (
// Is the help screen open
helpOpen = false
// L is the lua state
L *lua.LState
)
// LoadInput loads the file input for the editor
@@ -175,6 +180,13 @@ func main() {
os.Exit(1)
}
L = lua.NewState()
defer L.Close()
if err := L.DoFile("plugin.lua"); err != nil {
panic(err)
}
encoding.Register()
tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
@@ -207,6 +219,10 @@ func main() {
messenger = new(Messenger)
view := NewView(buf)
L.SetGlobal("view", luar.New(L, view))
L.SetGlobal("settings", luar.New(L, &settings))
L.SetGlobal("messenger", luar.New(L, messenger))
for {
// Display everything
Redraw(view)