]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/micro.go
Rename to tabstospaces for consistency
[micro.git] / cmd / micro / micro.go
index 4665220b3300a7986da637f41910b9040bdbca6a..718d220d6b7937b09262217ea393b463b7acaa68 100644 (file)
@@ -5,12 +5,15 @@ import (
        "fmt"
        "io/ioutil"
        "os"
+       "runtime"
 
-       "github.com/gdamore/tcell"
-       "github.com/gdamore/tcell/encoding"
        "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"
 )
 
 const (
@@ -41,6 +44,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 +181,9 @@ func main() {
                os.Exit(1)
        }
 
+       L = lua.NewState()
+       defer L.Close()
+
        encoding.Register()
        tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
 
@@ -182,8 +191,11 @@ func main() {
        InitConfigDir()
        // Load the user's settings
        InitSettings()
+       InitBindings()
        // Load the syntax files, including the colorscheme
        LoadSyntaxFiles()
+       // Load the help files
+       LoadHelp()
 
        buf := NewBuffer(string(input), filename)
 
@@ -204,6 +216,14 @@ func main() {
        messenger = new(Messenger)
        view := NewView(buf)
 
+       L.SetGlobal("OS", luar.New(L, runtime.GOOS))
+       L.SetGlobal("view", luar.New(L, view))
+       L.SetGlobal("messenger", luar.New(L, messenger))
+       L.SetGlobal("GetOption", luar.New(L, GetOption))
+       L.SetGlobal("AddOption", luar.New(L, AddOption))
+
+       LoadPlugins()
+
        for {
                // Display everything
                Redraw(view)
@@ -241,8 +261,8 @@ func main() {
                                        }
                                case tcell.KeyCtrlG:
                                        if !helpOpen {
-                                               helpBuffer := NewBuffer(helpTxt, "")
-                                               helpBuffer.name = "Help"
+                                               helpBuffer := NewBuffer(helpTxt, "help.md")
+                                               helpBuffer.Name = "Help"
                                                helpOpen = true
                                                view.OpenBuffer(helpBuffer)
                                        } else {