]> git.lizzy.rs Git - micro.git/commitdiff
Add linter plugin support
authorZachary Yedidia <zyedidia@gmail.com>
Sat, 3 Aug 2019 06:46:25 +0000 (23:46 -0700)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 25 Dec 2019 22:05:10 +0000 (17:05 -0500)
cmd/micro/initlua.go
cmd/micro/micro.go
internal/action/bufpane.go
internal/action/command.go
internal/buffer/message.go
internal/config/plugin.go
internal/config/runtime.go
internal/lua/lua.go
internal/shell/job.go
internal/util/util.go
runtime/plugins/linter/linter.lua

index 804f1142c3135d0bdb7312d76689e6a61f444ec5..a166b1fd4c1371cac6313cbf15e7aa4b6cf6c731 100644 (file)
@@ -80,7 +80,7 @@ func luaImportMicroUtil() *lua.LTable {
 
        ulua.L.SetField(pkg, "RuneAt", luar.New(ulua.L, util.LuaRuneAt))
        ulua.L.SetField(pkg, "GetLeadingWhitespace", luar.New(ulua.L, util.LuaGetLeadingWhitespace))
-       ulua.L.SetField(pkg, "", luar.New(ulua.L, util.LuaIsWordChar))
+       ulua.L.SetField(pkg, "IsWordChar", luar.New(ulua.L, util.LuaIsWordChar))
 
        return pkg
 }
index 06e1f968ebd41c3b2ad789a4894afd855f275291..62a41b42d4c1fe06f78b4c280f5b4c68f77dde24 100644 (file)
@@ -4,6 +4,7 @@ import (
        "flag"
        "fmt"
        "io/ioutil"
+       "log"
        "os"
        "sort"
 
@@ -172,7 +173,10 @@ func main() {
                screen.TermMessage(err)
        }
 
-       config.LoadAllPlugins()
+       err = config.LoadAllPlugins()
+       if err != nil {
+               screen.TermMessage(err)
+       }
        err = config.RunPluginFn("init")
        if err != nil {
                screen.TermMessage(err)
@@ -234,6 +238,7 @@ func main() {
                select {
                case f := <-shell.Jobs:
                        // If a new job has finished while running in the background we should execute the callback
+                       log.Println("OUTPUT:", f.Output)
                        f.Function(f.Output, f.Args...)
                case event = <-events:
                case <-screen.DrawChan:
index fcc15bbadac9c4d9493171149461908f6752415b..edf81ebe2772aa38ab04b36100fd54ddd24d90d4 100644 (file)
@@ -1,6 +1,7 @@
 package action
 
 import (
+       "log"
        "strings"
        "time"
 
@@ -261,7 +262,8 @@ func (h *BufPane) DoKeyEvent(e Event) bool {
                                                // canceled by plugin
                                                continue
                                        }
-                                       if action(h) && h.PluginCB("on"+estr) {
+                                       rel := action(h)
+                                       if h.PluginCB("on"+estr) && rel {
                                                h.Relocate()
                                        }
                                }
@@ -271,7 +273,9 @@ func (h *BufPane) DoKeyEvent(e Event) bool {
                if !h.PluginCB("pre" + estr) {
                        return false
                }
-               if action(h) && h.PluginCB("on"+estr) {
+               rel := action(h)
+               log.Println("calling on", estr)
+               if h.PluginCB("on"+estr) && rel {
                        h.Relocate()
                }
                return true
index 4e9f9d385557d9b6627835d950d54833fc9be138..0cff15bfd705afe87f603e0bff92d6d8de0153c1 100644 (file)
@@ -367,8 +367,13 @@ func SetGlobalOptionNative(option string, nativeValue interface{}) error {
                }
        } else {
                for _, pl := range config.Plugins {
-                       if option == pl.Name && nativeValue.(bool) && !pl.Loaded {
-                               pl.Load()
+                       if option == pl.Name {
+                               if nativeValue.(bool) && !pl.Loaded {
+                                       pl.Load()
+                                       pl.Call("init")
+                               } else if !nativeValue.(bool) && pl.Loaded {
+                                       pl.Call("deinit")
+                               }
                        }
                }
        }
index 8f072333dbac1e87199b0cee71a6c44a3e5ffab4..065d96668e3adbb9b18362da76afaa01b784131c 100644 (file)
@@ -17,10 +17,10 @@ type Message struct {
        Msg        string
        Start, End Loc
        Kind       MsgType
-       Owner      int
+       Owner      string
 }
 
-func NewMessage(owner int, msg string, start, end Loc, kind MsgType) *Message {
+func NewMessage(owner string, msg string, start, end Loc, kind MsgType) *Message {
        return &Message{
                Msg:   msg,
                Start: start,
@@ -30,8 +30,8 @@ func NewMessage(owner int, msg string, start, end Loc, kind MsgType) *Message {
        }
 }
 
-func NewMessageAtLine(owner int, msg string, line int, kind MsgType) *Message {
-       start := Loc{-1, line}
+func NewMessageAtLine(owner string, msg string, line int, kind MsgType) *Message {
+       start := Loc{-1, line - 1}
        end := start
        return NewMessage(owner, msg, start, end, kind)
 }
@@ -64,7 +64,7 @@ func (b *Buffer) removeMsg(i int) {
        b.Messages = b.Messages[:len(b.Messages)-1]
 }
 
-func (b *Buffer) ClearMessages(owner int) {
+func (b *Buffer) ClearMessages(owner string) {
        for i := len(b.Messages) - 1; i >= 0; i-- {
                if b.Messages[i].Owner == owner {
                        b.removeMsg(i)
index 8023c266a54779867a2450e676fa44b8fbf72cbb..dffad4853d47306b51754a406e8b2fb5292465c1 100644 (file)
@@ -2,6 +2,7 @@ package config
 
 import (
        "errors"
+       "log"
 
        lua "github.com/yuin/gopher-lua"
        ulua "github.com/zyedidia/micro/internal/lua"
@@ -10,10 +11,15 @@ import (
 var ErrNoSuchFunction = errors.New("No such function exists")
 
 // LoadAllPlugins loads all detected plugins (in runtime/plugins and ConfigDir/plugins)
-func LoadAllPlugins() {
+func LoadAllPlugins() error {
+       var reterr error
        for _, p := range Plugins {
-               p.Load()
+               err := p.Load()
+               if err != nil {
+                       reterr = err
+               }
        }
+       return reterr
 }
 
 // RunPluginFn runs a given function in all plugins
@@ -68,7 +74,7 @@ type Plugin struct {
 
 func (p *Plugin) IsEnabled() bool {
        if v, ok := GlobalSettings[p.Name]; ok {
-               return v.(bool)
+               return v.(bool) && p.Loaded
        }
        return true
 }
@@ -77,7 +83,7 @@ var Plugins []*Plugin
 
 func (p *Plugin) Load() error {
        for _, f := range p.Srcs {
-               if !p.IsEnabled() {
+               if v, ok := GlobalSettings[p.Name]; ok && !v.(bool) {
                        return nil
                }
                dat, err := f.Data()
@@ -98,6 +104,7 @@ func (p *Plugin) Load() error {
 
 func (p *Plugin) Call(fn string, args ...lua.LValue) (lua.LValue, error) {
        plug := ulua.L.GetGlobal(p.Name)
+       log.Println(p.Name, fn, plug)
        luafn := ulua.L.GetField(plug, fn)
        if luafn == lua.LNil {
                return nil, ErrNoSuchFunction
index 8ed43a0a252c7c797a574cdbcf0702cd38f1a291..905b354b171767149ee6dc36a5a89ecf70daf92e 100644 (file)
@@ -1031,7 +1031,7 @@ func runtimeHelpTutorialMd() (*asset, error) {
        return a, nil
 }
 
-var _runtimePluginsAutocloseAutocloseLua = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x56\xd1\x6a\xe3\x3a\x10\x7d\xcf\x57\x0c\xbe\x0f\xb1\x69\x9c\x4b\xee\xd3\xa5\xe0\x85\x6d\xb7\x94\x40\xe8\x2e\x69\x4b\x77\x69\x0b\x95\xe5\x71\x2c\xea\x48\x66\x3c\xda\x74\x29\xfd\xf7\x45\x76\x92\xda\xa9\xeb\x26\x50\x3f\x28\xb6\x66\x8e\x66\x74\x74\x66\x94\xdc\x48\x91\x83\xb5\xac\x72\x88\x40\x2d\x0b\x43\xec\x7b\x4b\x25\xc9\xfc\xeb\x26\xbd\x60\x50\xbb\x54\x53\xbb\x2e\x5b\xab\xe5\xf4\xff\x86\xd1\x7d\x6e\x6d\xc2\xb2\x91\xb9\x29\xf1\x87\x50\x54\x42\x04\xcf\xde\x9d\x77\xe7\x79\x23\xf0\x86\x43\x37\x3e\x3c\xb8\xd1\x0f\xdc\xf8\xfc\xe2\xc6\xdb\x7b\xef\xa5\x81\xbe\xc0\x55\xae\x74\x03\xff\xc6\x77\x90\x5a\x2d\x59\x19\x0d\x32\x13\xf4\x95\xfd\x92\x69\x04\x2a\x18\x00\x00\x84\x21\xe4\x56\x80\xd2\x09\x3e\x29\xbd\x00\x55\x82\xd1\x08\x26\x4d\x21\x25\xb3\x84\x85\xa9\xdc\x08\xd9\x92\xae\xb9\x18\xcf\xad\xc6\xed\x32\xe1\x24\x18\xa0\x4e\x1a\x51\x8c\x76\x0e\x7e\x5c\x8c\x80\xea\x20\xa9\x21\x50\x10\xc1\x64\x04\xff\xec\xec\x38\xa9\xd7\x77\x8f\x4a\x81\x20\x8a\x36\x59\xb6\x1d\x6f\xd5\xfd\x08\xfe\x0b\x80\x33\xd4\x5b\x84\x7b\x6a\x26\xa4\xa5\x99\xd2\x08\x11\xc4\xc5\xf8\xc4\xa6\xc7\xee\xcb\x8f\x8b\xf1\xa9\xa5\xd2\xd0\xf8\x57\x30\x68\xa1\x54\xba\x09\xb3\x46\x8e\xe0\xd5\xf9\xe7\xd1\x24\x38\x3c\x11\xf7\xc4\xc5\xf1\x89\x90\x8f\x65\x21\x24\xfa\x41\x97\xb9\x0e\x31\x57\x8b\x8c\xbb\x1c\x08\xc5\x63\x6b\xb6\xa2\x76\x27\xf3\x46\xa6\xf0\x05\x26\x20\x74\x02\x7e\x7d\x34\xd3\xf2\xc6\x50\x72\x9a\x09\xf2\x7b\xf6\x17\x4e\x82\x00\x0c\xf5\x51\x10\x7e\x44\x81\x5b\xa2\x9b\x83\xce\x3d\x74\xbd\x7f\x7c\xe0\x93\xcf\x3c\xf0\x26\x6d\x51\x54\x95\x65\x25\xe5\x53\x63\x35\x4f\xf5\x25\x93\xd2\x8b\x0d\x19\x15\x3f\xda\x30\x1c\xc2\xeb\xd1\xbb\xa4\x84\xa1\x9b\x87\x61\x38\x84\x0c\x09\x5d\x99\xb1\x81\x04\x09\x53\xd4\x12\x2b\x63\x61\x94\x66\x24\x67\x78\x5d\x73\x66\x24\xac\x32\x25\x33\x07\x71\x0c\x2d\x05\x2b\x29\xf2\xfc\x0f\x2c\x45\x82\x5d\x81\x56\x19\x6a\x90\x46\xff\x46\x62\x57\xd2\x0b\x03\x25\x93\x95\x5c\xc5\xcc\xad\xe8\x02\x4d\x19\x34\x62\x52\xb9\xc4\xb8\xce\x8c\x5c\x6e\x09\xc4\x28\x85\x2d\xeb\x24\xb7\x55\x8e\x4f\x05\xba\x25\x05\x68\xa3\xb7\xb9\xd7\x81\x3a\x84\x5f\x9d\xd1\x54\x97\x48\xec\x87\xad\xed\x8d\x7a\xeb\xac\xa7\x88\x66\x98\xee\x5f\x43\xbb\xef\x9b\xdf\x75\x63\x4b\x45\x5e\xe2\x4e\x1f\x2b\x08\xeb\x84\xd7\x2d\xd6\x8f\x8b\x3a\xda\xde\x0a\x6c\x39\x3b\xa9\x41\xd4\x57\x73\x4d\x80\xc6\x27\xfe\x18\x71\x34\x69\x62\x56\xee\x02\xa8\xf5\x7a\x8e\x3c\x43\x91\x28\xbd\xb8\xc9\x14\x63\xdd\x90\x36\xd2\x1e\x74\x36\xe5\xd6\x45\xd2\x6e\xcb\xdb\xec\x5b\xb5\xda\x04\xbc\x5b\xad\x2a\x6d\x6c\xa5\x1f\xde\xd3\x54\xdb\xe7\xd0\xa9\x89\xda\xe5\x4a\xc4\x9d\xe6\x3e\xf9\x79\x77\xda\x83\xf1\x18\x56\x65\xe7\xc2\x97\x2c\x88\xbf\xa7\xb3\x77\x23\xf7\xaa\xb1\xa5\xaf\x7d\x44\xd9\x54\x25\x93\xed\x10\xe5\xeb\x0d\xb3\x11\xe4\x7e\xf7\xeb\x41\xb2\x85\x4f\xb9\x24\xdd\xcd\xd4\x27\xf8\xc3\xbb\x7f\x5c\x1c\x7f\xc3\x1c\xb9\x79\x16\x6f\xe8\xab\xfe\x7f\x8d\x67\x66\xe1\x7b\xf3\xb3\xab\xeb\xf9\xc5\xf4\xe2\x1c\xae\xae\xe7\x67\x5e\xd0\x49\xef\xdf\x00\x00\x00\xff\xff\x35\x67\xdf\x19\xe9\x09\x00\x00"
+var _runtimePluginsAutocloseAutocloseLua = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x55\xd1\x6a\xdb\x4a\x10\x7d\xf7\x57\x0c\xba\x0f\x96\x88\xe5\x8b\xef\xd3\x25\xa0\x42\x93\x42\x31\x98\xb6\x24\x85\xb4\x24\x81\xac\x56\xb3\xd6\x12\x79\x57\x8c\x66\xeb\x94\x90\x7f\x2f\x2b\xd9\x8e\xe4\x2a\xb2\x0d\xd1\xc3\xda\xd2\xce\xd9\x99\x3d\x73\x66\xa6\xb0\x52\x14\xe0\x1c\xeb\x02\x12\xd0\xab\xd2\x12\x87\xc1\x4a\x4b\xb2\xff\xfa\x8f\x41\x34\xda\x98\xb0\xfa\xbf\x65\xe1\x5f\x77\x7b\xc2\xb1\x95\x85\xad\xf0\x9b\xd0\x54\x41\x02\xcf\xc1\x5d\x70\x17\x04\x13\x08\xc6\x63\xbf\x3e\x3c\xf8\x35\x8c\xfc\xfa\xfc\xe2\xd7\xdb\xfb\xe0\xa5\x85\xfe\x82\xeb\x42\x9b\x16\xfe\x2f\xdb\x91\x72\x46\xb2\xb6\x06\x64\x2e\xe8\x23\x87\x15\xd3\x04\x74\x34\x02\x00\x88\x63\x28\x9c\x00\x6d\x32\x7c\xd2\x66\x09\xba\x02\x6b\x10\xac\x52\xa0\xc8\xae\x60\x69\x6b\x33\x42\x76\x64\x9a\xdb\x4e\xaf\x9c\xc1\xdd\x31\xf1\x2c\x1a\xa1\xc9\x5a\x5e\xac\xf1\x06\x61\x5a\x4e\x80\x1a\x27\xca\x12\x68\x48\x60\x36\x81\x7f\xf6\x6e\x9c\x35\xe7\xfb\x47\x2b\x20\x48\x92\x6d\x94\x5d\xc3\x5b\x7d\x3f\x81\xff\x22\xe0\x1c\xcd\x0e\xe1\x9f\x86\x09\xe9\x68\xa1\x0d\x42\x02\x69\x39\xbd\x70\xea\xdc\xbf\x85\x69\x39\xbd\x74\x54\x59\x9a\xfe\x8c\x46\x1d\x94\x56\x5b\x37\x1b\xe4\x04\x5e\x8d\x7f\x9c\xcd\xa2\xd3\x03\xf1\x4f\x5a\x9e\x5f\x08\xf9\x58\x95\x42\x62\x18\xf5\x6d\x37\x2e\xae\xf4\x32\xe7\x3e\x03\x42\xf1\xd8\xf9\x5a\x53\xbb\x17\x79\x2b\x52\xf8\x00\x33\x10\x26\x83\xb0\x49\xcd\xbc\xba\xb1\x94\x5d\xe6\x82\xc2\x81\xfb\xc5\xb3\x28\x02\x4b\x43\x14\xc4\x87\x28\xf0\x47\xf4\x73\xd0\x7b\x87\xbe\xff\x87\x13\x3e\x7b\xcf\x84\xb7\x69\x4b\x92\xba\x2c\x6b\x29\x5f\x5a\x67\x78\x6e\xae\x99\xb4\x59\x6e\xc9\xa8\xf9\x31\x96\xe1\x14\x5e\xcf\xde\x24\x25\x8e\xfd\x77\x18\xc7\x63\xc8\x91\xd0\x97\x19\x5b\xc8\x90\x50\xa1\x91\x58\x6f\x96\x56\x1b\x46\xf2\x1b\xaf\x67\x2e\xac\x84\x75\xae\x65\xee\x21\x9e\xa1\x95\x60\x2d\x45\x51\xfc\x86\x95\xc8\xb0\xcf\xd1\x3a\x47\x03\xd2\x9a\x5f\x48\xec\x4b\x7a\x69\xa1\x62\x72\x92\x6b\x9f\x85\x13\x7d\xa0\x39\x83\x41\xcc\x6a\x93\x14\x37\x91\x91\x8f\x2d\x83\x14\xa5\x70\x55\x13\xe4\xae\xca\xf1\xa9\x44\x7f\xa4\x00\x63\xcd\x2e\xf6\xc6\x51\x8f\xf0\xeb\x1c\xcd\x4d\x85\xc4\x61\xdc\xb9\xde\x64\xb0\xce\x06\x8a\x68\x81\xea\xf8\x1a\xda\xff\xbf\xfd\xdd\x34\x36\x25\x8a\x0a\xf7\xfa\x58\x49\xd8\x04\xbc\x69\xb1\x61\x5a\x36\xde\x8e\x56\x60\xc7\xd8\x4b\x0d\x92\xa1\x9a\x6b\x03\x0c\x3e\xf1\x61\xc4\xd9\xac\x8d\x59\xfb\x01\xd0\xe8\xf5\x33\xf2\x02\x45\xa6\xcd\xf2\x26\xd7\x8c\x4d\x43\xda\x4a\x7b\xd4\xdb\x94\x3b\x83\xa4\xdb\x96\x77\xd1\x77\x6a\xb5\x0d\x78\xb3\x5a\xb5\x6a\x5d\x65\x18\x3e\xd0\x54\xbb\x79\xe8\xd5\x44\x63\xf2\x5d\xa4\xbd\xdb\x43\xf2\x0b\xee\x4c\x00\xd3\x29\xac\xab\xde\x83\xaf\x59\x10\x7f\x55\x8b\x37\x3d\x0f\xaa\xb1\xa3\xaf\x63\x44\xd9\x56\x25\x93\xeb\x11\xe5\xeb\x84\xd9\x0a\xf2\xb8\xf9\x7a\x92\x6c\xe1\x5d\x86\xa4\x9f\x4c\x43\x82\x3f\xbd\xfb\xa7\xe5\xf9\x27\x2c\x90\xdb\xb9\x38\x48\xdf\x9f\x00\x00\x00\xff\xff\x80\x29\x13\xa7\xab\x09\x00\x00"
 
 func runtimePluginsAutocloseAutocloseLuaBytes() ([]byte, error) {
        return bindataRead(
@@ -1071,7 +1071,7 @@ func runtimePluginsFtoptionsFtoptionsLua() (*asset, error) {
        return a, nil
 }
 
-var _runtimePluginsLinterLinterLua = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x57\xdb\x8e\xdb\x36\x13\xbe\xf7\x53\x0c\x88\x5f\x80\xb4\x96\x94\xbf\x41\xaf\x0c\x08\x45\xba\x6d\x02\x14\x39\x14\xd8\xb4\xbd\xe8\x36\x05\x2d\x8d\x6c\x66\x29\x52\x20\x29\x1f\x60\xe4\xdd\x0b\x92\xb2\x2c\xc9\xf4\xf6\x80\x2c\xb0\xcb\x11\x39\x9c\xef\x9b\x03\xc9\x59\x56\xc3\x1b\x34\x1f\x5a\xc3\xa4\x88\x09\x67\xc2\xa0\x22\x09\x14\x05\x08\xc6\xc1\x6c\x51\x2c\x00\x00\x5e\x55\xd5\x4c\x27\x05\xa3\x3a\x4c\x16\x28\xaa\xc5\xe2\x1d\x7d\xc2\x7b\xd9\x34\x54\x54\x5e\x81\xa4\xd0\x2b\xe6\x76\xe8\xd7\x48\x0a\xff\x4f\x16\x8b\xba\x13\xa5\xb5\x05\xa3\xa5\x38\x71\x38\xf7\x9d\xfa\x95\xe1\x3e\x4e\x56\x0f\x74\x87\x71\x4d\xb9\x46\xbf\xa2\x3a\xf1\xd6\x19\x8c\x7b\xcc\xc1\xca\x78\xc5\x6a\x72\x59\x52\x0e\xb5\x81\xe2\x62\x2e\xff\xbe\xab\x57\xaf\x19\xc7\x8f\xc7\x16\xa7\x7a\x8c\xe3\x5c\x33\xff\x99\x9a\xed\x48\xa7\x62\x0a\x0a\xf8\x81\x29\x2c\x8d\x54\xc7\xf7\xb4\xc1\xd8\xee\xf3\x76\x58\x0d\x1f\x1e\x6c\xc4\xc8\x9e\x89\x4a\xee\x35\xb9\xc4\xcd\xfe\x54\xb8\x13\x1d\xe7\x50\x00\x79\xff\xcb\x5b\xe2\xe6\x91\x6b\x0c\x29\xbc\xa8\x70\xf7\xc2\x7e\xf4\x6a\xd6\xd1\x1e\xc3\x3a\x54\x00\x29\x67\xd6\x6d\x0c\x63\xb2\x29\x4b\x1b\x72\x3f\x9c\x48\x56\xeb\xa3\x30\xf4\x90\x49\xc1\x8f\x76\x21\xfb\x8d\x72\xee\x05\x3c\x18\x45\x49\xea\x1c\xff\x92\x02\x89\xea\x55\xc4\x57\x51\xb5\x5c\xe5\xcb\x15\x44\x0d\x49\x06\x86\x23\xd4\xe5\xf2\x3f\xe0\x92\x4c\x9b\xaa\x28\x97\xcb\x6f\xbe\xfd\x1a\x24\xaa\x20\x85\xaa\xb1\x75\xd5\x0f\x27\x92\x95\x92\x4b\x55\xc8\xba\x76\x48\x32\x73\xc3\xde\xff\x65\x6e\x28\x27\xc0\x51\x1c\xf1\x28\x79\x0e\x77\x23\xc3\xbe\xcb\x75\xc7\xb8\x03\xdf\x48\x87\x3d\x7c\x67\xf6\xbb\x4f\xeb\xc5\xbd\x8b\xfd\xb1\x91\xf3\x71\x19\xa4\xd3\x75\x50\x6e\x31\xfb\x4c\x77\x34\xc8\xcd\x2e\xb8\xcc\x9c\x85\x13\xc9\x2c\xb3\x8a\xa9\x79\xd0\x01\x95\x92\xea\x59\x08\x5d\x2a\xd6\x9a\x30\x90\xde\xf6\xfc\x07\x69\xcc\xdf\x6a\x21\x44\x3c\xcd\x97\xe9\x15\x82\x36\x8a\x89\x4d\xde\x50\x53\x6e\xe3\xda\xb8\x2b\xc3\xa0\xa2\x06\x49\x12\xc2\x1a\x56\xbd\x66\x9f\xee\xeb\x2a\x0a\x3b\xc2\xbb\x70\xa8\x78\x47\xcb\x2d\x96\x4f\xce\xea\x45\x3e\x91\x2c\x13\xd2\x57\x53\xb0\x50\x6f\x05\x4c\xb0\x26\x88\x63\xe7\x53\xe8\x87\x13\x19\x30\xb3\x8c\x33\x6d\x5e\x77\x9c\xdb\x5b\x47\xfb\x29\x6d\x2a\xd9\x19\x2f\xdb\xb0\xea\x95\x2f\xe8\x0b\x8d\x3c\xe2\x29\x44\xd5\x32\xbf\xc5\xe3\xc3\xfa\x33\x96\x86\xed\x30\xbb\x0f\xf2\x29\x39\x15\x1b\x8b\x70\x28\x55\x27\x3c\xa7\xf3\xd4\x57\xbf\x3f\xda\xa3\xd9\x4a\x11\xe4\xd1\x1e\x6b\x4e\x9f\xd0\x39\x3e\x92\x67\xa7\x20\xcf\x56\xdf\x85\xce\x4f\x73\x6c\x1d\xc1\x7e\x9c\xed\x0a\xed\x68\x8f\xe7\x13\x37\x48\x36\xd7\xb2\x33\x6d\x67\xb2\x5a\xaa\x86\x9a\xa2\xa5\x4a\x23\x5d\x73\xf4\x29\x50\xd8\x4a\x65\x74\x21\xe4\x95\xe3\xb7\x3c\xd6\x5b\xe4\x3c\xe8\xb0\xde\xd6\x8d\xc3\x3f\x0b\xff\xe2\xc0\xeb\x3d\xab\x0d\x01\x2a\xaa\xf3\x9b\x53\x51\xb5\x67\xe1\xc8\xea\x3d\x33\x75\x39\x4d\xb1\x33\x10\x38\x33\xcf\xa7\xef\x1a\x96\x33\xd1\x1d\xfe\x06\x75\xc0\x0a\x38\xf8\x0c\xd8\x91\x36\xe1\xc0\xb9\x85\xd4\x2b\x8c\x32\xe7\x53\xe6\x12\x4a\x95\xee\x93\x16\x42\x1c\x01\x8a\x6a\xd6\x44\x48\xe1\x1a\x8e\x1d\xc3\xfd\xf0\xaa\x87\x1a\xa3\x09\xad\x79\xe7\x31\x79\xd5\x2f\xad\xcc\x3d\x47\xaa\x5e\x71\xfe\xa6\x33\x06\xd5\x3b\xd4\x9a\x6e\x50\xc7\xb7\xa8\x38\x67\x3d\x60\x0a\x65\x53\xa5\x40\xd5\x46\xa7\xfe\x9e\xf6\xce\xce\x9b\x25\x87\x30\x33\xef\x2d\x24\xbe\x7f\xf8\x49\xae\x1f\x5a\xba\x17\xf1\xc8\x1e\x21\xfd\x6f\xdf\xa8\x49\xf1\xe3\xc1\xdd\xaa\x67\xec\x09\xe0\x3c\x5c\x56\x37\xf6\x87\xe6\xc6\x0e\x18\xfa\x27\xfb\x08\x68\x28\x40\xb7\x7c\xb4\x89\x3c\x0a\xd2\xd3\xf3\x6a\x0a\x37\x78\x80\x62\x6c\x65\xb5\xd1\xdd\x3a\x26\x51\xe4\x5e\xf3\x38\xcf\xb3\x84\x24\xc3\xa4\xab\x86\x38\xaa\x96\xe3\xc9\xc6\x6b\xda\x39\x67\xbb\x96\x0a\xfe\x4c\xdd\x3b\xc4\x04\xb0\x96\x32\xe5\x82\x83\x3a\x81\x4a\x0e\xe9\xca\x32\xf8\xa8\x58\x03\xfb\x2d\x33\xa8\x5b\x5a\xe2\xb8\xfa\x6c\x8b\x68\x87\x95\x7f\xac\xc8\xa7\x48\xdf\x59\x8c\x48\xdf\xfd\x6f\x74\xc3\x5c\x1e\xb5\x9a\x89\xca\xa1\xa4\xde\xad\x59\xe5\xc0\xa4\xff\x74\x01\xc4\x14\x1a\xbd\xb1\x51\x1a\x3f\x8b\x63\x13\x93\xdd\xac\x86\x35\xd5\x28\x6c\x2f\x7a\xdd\xbc\xba\x0e\x7e\x58\x77\xbd\xea\x35\x81\x69\x0d\x4d\xca\x67\xa8\x3f\x23\x45\xd7\xac\x51\x39\x22\x89\xa3\x98\xc2\xcb\x29\x15\x5b\x1a\x73\xf9\xba\xac\x7d\xf2\xb5\x51\x29\x68\x6c\x93\x49\xde\x75\xc7\x6d\xbb\x7e\xfa\x12\xa8\x86\x98\xc4\xbf\x7f\x8a\xf4\x1f\x2e\xc9\xbe\x2a\xe2\xc1\x80\x4d\x2e\xd2\x72\x6b\x53\xab\x8d\x5a\x6d\x7c\xd4\xfa\x90\x8f\xd2\x6b\xec\xbd\x90\x33\xa1\x51\x99\xd8\x03\xa6\x6e\xe7\xe5\x14\xba\x13\x8d\xa6\x53\xa2\x67\x34\x73\x60\x1a\xce\x11\x53\x8d\xad\xeb\xdd\xc9\x3f\xfa\x77\xa0\xd7\x7e\x7c\x24\x13\x64\x6f\xca\xda\xbf\x94\x80\x2b\x69\x5f\x20\x24\xce\xef\x08\xe4\xb9\xdb\x9e\xe7\x40\x92\x38\xbf\x4b\x6c\xa9\x47\x2f\xfb\x02\xec\xb9\x5b\x13\x8e\xf9\x5f\x01\x00\x00\xff\xff\x43\x20\x8f\x97\xdb\x0d\x00\x00"
+var _runtimePluginsLinterLinterLua = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x58\x7b\x8f\xdb\xb8\x11\xff\xdf\x9f\x62\x20\x54\x80\x14\x4b\x5a\xb4\xe8\x5f\x02\x8c\x22\x6d\x73\x45\x8b\x5c\x52\x60\xd3\x07\x90\xe4\x0a\x5a\x1a\xd9\xbc\xa5\x48\x95\xa4\xec\x75\x17\xf9\xee\xc5\x90\x94\x4c\xf9\xb1\xbd\xb6\x67\xc0\xe2\x43\xf3\x9e\x1f\xc9\xa1\x84\x6a\x98\x00\x3d\x4a\xcb\x7b\x84\x0d\xf0\x7e\x50\xda\x66\x49\x98\x49\xf2\x95\xa7\xe8\xb8\xc0\x81\xd9\x7d\x44\x42\xc3\x87\x69\x7e\x26\x34\x7b\x14\x22\xa2\xea\x79\xa3\xd5\x83\x9b\x9d\x69\xb6\x63\xd7\xa1\xbe\x22\xf2\xd3\x33\x95\x9b\xbc\x24\x4a\xf2\x55\x78\x2d\xb8\xb4\xa8\x0d\x6c\xe0\xe5\xdb\x6a\x55\x96\xd0\x68\x64\x16\x0d\xb0\xf0\x0a\x50\x5a\x7d\x2a\xa0\x61\x42\x40\xa7\x55\x0f\x47\x6e\xf7\x5c\x02\x93\xc0\x25\xb7\x9c\x09\xfe\x2f\x66\xb9\x92\xd0\x8d\xb2\xa1\x4e\x01\x52\x59\x92\xd5\x72\x8d\x8d\x15\x27\x60\x76\xa2\x05\xa1\x58\x0b\x14\x94\x55\x59\x12\x8d\x64\x3d\xd6\xee\x09\xaa\x03\xbb\xc7\xa0\x97\xde\x51\x58\xec\x69\xc0\x7a\xee\x81\x55\xd0\xec\xb1\x79\x82\x4e\x69\x1a\x8c\x26\x66\x68\xfa\xb6\x86\x9e\x71\x39\x19\x3f\x68\xd5\xa0\x31\x60\xf7\x64\x82\x01\x7c\xc6\x66\xb4\xd8\x12\x31\xd3\x3b\x53\xd3\x73\xec\x51\x5a\x43\xd2\x06\x66\x5c\x7b\x36\x63\x92\x40\x0c\xf4\x23\x7d\x69\x47\x34\x1a\x29\xfa\x81\xb8\x19\xb5\x46\x69\x9d\x9d\xce\x99\x05\x7d\x7b\x97\xde\x47\x48\xe9\xd3\xcc\x84\x5a\x2b\xdd\x29\xdd\x33\x5b\xc3\x5e\x1d\xbd\x59\xda\x60\x64\xd4\x43\xa3\xfa\x81\x8b\xc8\x3f\x35\xda\x61\xb4\x93\xd2\xb4\xf3\x11\x2b\x20\x15\x35\xf1\x20\xc8\xb1\xdf\xa2\x2e\x20\xed\x6b\xaf\xe2\xe1\xc8\xb4\xe4\x72\x07\x3d\x1a\xc3\x76\x4e\xb7\x32\x44\x6d\x2c\x65\xe2\xe3\x23\x45\x8d\x9b\x29\x0e\xdc\x80\x19\x07\xc2\x10\xb6\xa0\x34\x8c\x32\x1a\xca\x49\xb3\x1a\x08\x00\x4c\x90\xc9\xac\x2f\xa0\xc5\x8e\x8d\xc2\xd6\xf0\xf9\x2b\x91\x1c\xf7\xdc\x22\x69\xa8\xc1\xec\xd5\x28\x5a\xe7\xd4\xc7\x47\xaf\x75\x8b\xc0\x60\x2b\x58\xf3\xe4\x86\x59\xab\x08\x48\xb4\xac\xe2\x84\xb8\xc4\xef\xd1\x10\x9f\xc9\x9d\xd9\x1a\xd8\x59\x34\x64\x4a\x8a\xd3\x7f\xe6\x7a\xd5\xdc\x8e\x09\x83\x90\x05\x23\x67\x9b\x1c\x63\xab\x7a\x66\x9b\xfd\xc2\x85\x19\x9f\x5b\x04\xa7\x70\xd0\x48\x91\x61\x6e\x21\x8d\x0c\x06\x66\x2d\x6a\x49\xd9\x74\xdc\x6e\x15\x91\x34\xe2\x66\x8d\x1d\xc3\xee\x40\x42\x0a\xf2\x28\x12\x1e\x5c\x70\x6e\xb1\xc6\xf2\x03\xb3\x08\xca\xad\x40\x7c\x66\x8d\xf5\x12\x7f\xaa\x4f\x1a\xff\x39\x72\x8d\x31\x6b\xbe\x9a\x96\x2e\xf4\xec\x09\xdf\x3b\x7d\x19\x21\xb2\x88\x8c\x6a\xfa\xb6\x70\x8b\xa6\x88\x41\x5a\x80\x32\xc5\x39\xfa\xc5\x14\x9e\x7c\x45\xc6\xf0\x6e\xda\x61\x3e\x93\xb8\xaf\xb0\xd9\x80\xe4\x82\xdc\x92\x8e\x80\x7e\x17\x14\xb4\x13\xdd\x7c\x55\xcd\x51\xde\xcc\x66\xdd\xa1\x6c\xfa\x16\x36\x64\xf1\x9d\xf7\xe4\x06\x6c\x9c\x37\x77\x28\x22\x17\x61\x13\x3b\x7c\x87\x5e\x91\x3c\x65\x28\x75\x77\xed\x3f\x63\x74\x13\xe1\x55\x69\x9f\x9a\x3b\x4c\x21\x9e\xb0\x99\x22\xbb\x64\x40\xd9\xae\xe8\x7f\x4e\xa1\xc6\x5e\x1d\xe2\x24\xfa\x54\x5c\x46\x59\x72\x71\xc1\x48\x5b\x74\x16\x88\xdd\xe1\xd0\xe2\x41\x8e\xee\x1c\x4a\x1e\x5a\x3c\x3c\xd0\x20\x99\xf2\x1a\xce\xb6\xea\x0f\x1f\x3f\x3e\x52\x5a\x93\x23\x97\xad\x3a\x9a\x64\x99\xdc\x48\xc6\x87\xbf\xbc\x4f\x66\x9b\x5d\x27\x42\x5b\xb2\x6b\x9a\xa4\x80\xc4\x3d\x7c\xff\x25\x29\x3b\x73\x92\x96\x3d\x97\x84\x7d\x7a\x51\xfe\x8d\x09\xe1\x3b\xf8\x6c\x35\xa3\x6e\xda\x25\xdf\x5c\x53\xa7\xa2\x4e\xdb\x75\x5d\xad\x6b\x48\xfb\x24\xbf\xab\x62\xbd\x7e\x45\x49\x52\x1a\xdb\x6e\x9a\xf5\xfa\x97\xbf\xfe\xff\x35\xb6\x7d\x4b\x0c\xfe\xe1\xfa\x2f\x49\xd9\x28\xa1\xf4\x46\x75\x9d\x13\xab\x4a\xd7\x1c\xfd\x93\xbb\xa6\x59\x68\x49\xb3\x54\xa4\xf9\x2b\x6e\xa9\xed\xc8\x85\xd3\xb1\x53\xf3\xf3\x25\x99\x67\x4b\x1a\x87\x44\x9c\x0d\xbf\x27\x8c\x80\x12\xcb\x0a\xe3\x97\x6b\xb7\x6f\x4b\xf8\x91\x1d\x98\x73\x80\x3a\x53\x1b\x42\xed\xcc\x49\xdb\xab\x20\xfa\x05\x76\x4f\xa0\xd9\x07\x93\x48\x92\x69\x34\x1f\xfc\x68\x9a\x8f\x4d\xf3\xc7\x5d\x2a\x8a\x6a\x5d\xdc\x16\x27\xb8\x45\xcd\x2c\x92\x88\x8b\x7e\xc8\xcf\x75\x8e\x7b\x7a\xf3\xad\xf0\xeb\xae\x00\xab\x47\xbc\x21\x78\x64\xae\x36\x71\xc2\x46\x16\x9a\x69\xea\x25\x29\x4b\xa9\x7c\xf2\x6f\x82\xe8\xb6\xb5\x92\x93\xee\x65\xf3\x92\xcc\x7a\xca\x92\xf6\x90\xef\x46\x21\xfe\xcc\xec\xde\xf8\x29\x63\x5b\x35\x5a\xdf\xa7\x10\x99\x3a\x80\x6d\xd6\x59\xa5\xa2\x80\xb4\x5d\x57\xb7\x95\x36\x82\xc9\x1d\x31\xa8\xed\x8f\x48\x27\x0e\xfa\xa0\x3c\x37\x7a\x94\xde\x80\x89\xe2\x67\x5e\xa2\xc3\xa9\x13\xec\x09\x9d\x23\xc3\xc9\xee\x95\xf4\xbd\x79\xf6\x02\x86\x55\x59\xff\xe6\xb6\xa4\xfe\x34\x9c\x96\x52\xc2\xcc\x85\x84\x7b\x76\x4c\xcb\x20\xb6\x62\x5e\x0a\x65\xe9\x2b\xae\xd2\x9f\x09\x1b\x57\xa1\xb1\xad\x40\x1f\x74\x8d\x54\x19\x99\x8d\x54\xd7\x48\xbf\xa9\xce\xec\xbb\xde\x69\xf3\x25\xbe\xeb\xf8\x99\x9f\xbc\xec\xcc\x91\xdb\xce\x65\xc9\x1c\x79\x67\x97\xe9\x72\x53\x37\x70\x7d\x4e\x05\x51\xb5\x4c\x1f\xb9\xa4\xf7\xb7\x01\x7e\xa1\xa2\xb9\x6d\x5e\x24\x50\x70\x39\x3e\xdf\x97\x77\x62\xbd\xf3\x35\x6e\xa3\x10\xfb\xd8\xba\xc8\x33\x6d\xa6\xe8\xde\xd0\xe7\x03\xb2\x3c\xcc\x1a\x25\x2d\xe3\xd2\x64\xbe\x2a\x41\x81\x54\xe5\x7b\x1b\xa8\x18\x7c\x2a\xe0\x00\x5c\xc2\xc0\xb8\xf6\x44\x39\xb4\x6a\x3e\xb6\x78\x07\x07\x3a\xd5\x02\xdf\xf2\x4c\xa3\x9f\x46\x3b\x52\x3d\xa7\xc7\xf3\xc1\x4d\x16\xc4\x6d\xa0\xf1\x87\xf5\xc5\x21\x3d\xca\x10\x85\xed\xd8\xc5\x67\x6e\x47\xc5\xc1\x76\xec\xea\xef\xb8\xc0\x4f\xa7\x01\x17\x27\xb2\xbb\x5f\xb8\xf7\x15\xad\xf7\xf8\xac\xe6\x3a\x94\x45\x74\x91\xac\x7e\xcf\x75\x46\x83\x7c\x75\xd7\x63\x57\x0e\x2c\x9c\x9e\x2c\x98\x0a\x0e\xb2\x65\x03\x87\xea\xaa\xd8\xa2\xe8\xcc\x85\xc9\x55\x68\xce\x02\x8c\xd5\x5c\xee\x2a\x37\xcc\x3a\x5b\x44\xb2\xf2\x45\xd4\x2e\x4c\xd8\x33\x43\x45\xc5\x39\x89\x87\x8a\xaa\xcc\xb8\xe4\xc8\x63\x63\xe8\x9a\xe0\x79\x98\x6c\xe1\x10\x15\x5a\xaf\x18\xb7\x2c\xba\xa6\x9c\x05\x89\x67\x69\x24\xfb\x7f\x96\x38\x0f\x42\x02\x98\xde\x9d\x53\x70\x70\x65\xe8\x22\x03\xf4\xf3\xd3\x9f\x9f\xbe\xfa\x02\xb5\xde\x99\x71\x9b\x25\x69\x4a\x3b\xb8\x4b\xe9\x3c\x43\xe7\x68\xcb\xf5\x9d\x50\xf2\x6e\x36\xed\xca\x66\xca\x3e\x21\xaf\x70\xa8\xa8\x5c\x69\xef\xf5\x52\x1b\x55\xbb\xf9\x4d\x70\x2f\xb1\xac\xe4\x23\x3b\x60\xb6\x1d\xc2\x0a\xe7\x8d\x56\xd5\x7b\xb5\xcb\x92\xc7\xb7\x7f\x7d\x17\xb6\xaa\x08\xf0\x43\xf5\xdb\x09\xf3\xaf\xac\x90\xb3\x89\x1e\xaa\xf7\x2e\x20\x5e\x10\xad\x98\xdf\x09\x64\xfa\x7b\x7f\x9d\x9d\x00\x1e\xf0\xef\xb6\xd5\xea\x4f\x6a\xfb\x38\xb0\xa3\xcc\x22\x49\x49\x12\xfe\x9e\xbe\x52\xf2\xdd\xb3\x2b\x04\x16\xaa\x17\xfa\x2e\xbd\x27\x86\xcc\x9f\x07\xaf\xb1\x5d\xc4\xe6\xe3\x87\x77\x7f\xff\xe3\xa7\xe4\x72\xde\xcb\x89\xd7\x3c\x15\x34\x74\xb9\x30\x83\x88\xf4\x24\x5f\x64\x12\x9c\x0b\x5f\x9f\x70\x87\xcf\xcb\xab\xca\x02\x3a\x49\x56\x55\x65\x9e\x9c\xd1\xe3\xb6\xdc\x2c\x6d\xd7\xf1\x64\xef\x29\x69\x6e\xde\x38\xfe\x51\xb8\x9a\x8a\x4b\xe0\xf3\xde\x81\x4b\xdc\x96\x25\x7c\xd2\xbc\xf7\xb7\x1a\x33\xb0\x66\x71\x9b\xa1\x2d\x8b\x9a\xda\x6f\x04\xc9\x0f\xa9\x79\x43\x3a\x52\xf3\xe6\x17\xc9\x62\x21\x87\x0d\xa3\xe3\xb2\x75\x5a\x0a\xef\x56\x7e\x03\xc1\xf3\x7e\xe8\xc2\x8d\x05\xf4\x66\x77\xb9\xe5\xc4\x22\x16\xdc\xbc\x83\x2d\x33\x48\x77\xa1\x6c\xda\x4c\x73\xda\xec\xe6\x59\xb7\xd2\xae\xd5\x9e\x55\x6f\xbd\x3e\xff\xb9\xad\xfa\x80\xc7\x80\xbc\xb7\xf6\x3d\x97\x98\x4d\x10\xe8\xcd\xae\x00\xab\xfc\xf7\x17\x67\x50\x5e\x4c\x4c\xdf\x7f\x7a\x47\xc9\xca\xaf\x34\x10\x9a\xdf\xb6\x6d\x90\x98\x91\xaa\x25\x51\xbc\x5b\xdd\x5f\x98\x1e\x31\xc6\xea\x02\x0c\x0e\xf9\x02\x2c\x66\x14\xf6\x7c\xd7\x5e\x42\x28\x4b\xb2\xcf\x3f\xa4\xe6\xab\x43\x86\x87\x52\x36\x0b\x20\x44\x20\x6b\xf6\x84\x07\x63\x75\xbd\xf3\xa1\x0e\x79\x8a\x30\x61\xe9\xc4\xae\xb8\x34\xa8\x6d\xe6\x15\x16\x8e\x33\xbf\x75\x48\x7a\x82\x0b\x07\x96\xd9\x88\x2c\x35\x38\xb8\x5b\xe9\x7f\x7b\x1b\x0d\x7c\x5f\xbe\x24\x0b\x1b\xbc\x50\xf7\x11\x72\x46\x90\x5b\x11\x1e\x5f\x49\x56\xbd\x49\xa0\xaa\x1c\x7b\x55\x41\x92\x67\xd5\x9b\xdc\x15\x23\xbf\x4a\x16\x1b\x99\xfb\x8a\x47\x52\xff\x1d\x00\x00\xff\xff\x9f\x7b\x2f\x98\x12\x16\x00\x00"
 
 func runtimePluginsLinterLinterLuaBytes() ([]byte, error) {
        return bindataRead(
index ddbcf3dec7461fa702a347201c4376b9cde99ae2..f85a4ff06d44290b0772db2e4fd5734a57b01781 100644 (file)
@@ -57,7 +57,7 @@ func Import(pkg string) *lua.LTable {
                return importRuntime()
        case "path":
                return importPath()
-       case "filepath":
+       case "path/filepath", "filepath":
                return importFilePath()
        case "strings":
                return importStrings()
@@ -67,7 +67,7 @@ func Import(pkg string) *lua.LTable {
                return importErrors()
        case "time":
                return importTime()
-       case "utf8":
+       case "unicode/utf8", "utf8":
                return importUtf8()
        default:
                return nil
index d3c33bf883e841d62e7de8a5a4246502469e28e6..3dfb8ced1e614b3184644fbb3423c5f1e8b33241 100644 (file)
@@ -32,17 +32,17 @@ func init() {
 // JobFunction is a representation of a job (this data structure is what is loaded
 // into the jobs channel)
 type JobFunction struct {
-       Function func(string, ...string)
+       Function func(string, ...interface{})
        Output   string
-       Args     []string
+       Args     []interface{}
 }
 
 // A CallbackFile is the data structure that makes it possible to catch stderr and stdout write events
 type CallbackFile struct {
        io.Writer
 
-       callback func(string, ...string)
-       args     []string
+       callback func(string, ...interface{})
+       args     []interface{}
 }
 
 func (f *CallbackFile) Write(data []byte) (int, error) {
@@ -55,13 +55,13 @@ func (f *CallbackFile) Write(data []byte) (int, error) {
 
 // JobStart starts a shell command in the background with the given callbacks
 // It returns an *exec.Cmd as the job id
-func JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...string) *exec.Cmd {
+func JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...interface{}) *exec.Cmd {
        return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
 }
 
 // JobSpawn starts a process with args in the background with the given callbacks
 // It returns an *exec.Cmd as the job id
-func JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit string, userargs ...string) *exec.Cmd {
+func JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit string, userargs ...interface{}) *exec.Cmd {
        // Set up everything correctly if the functions have been provided
        proc := exec.Command(cmdName, cmdArgs...)
        var outbuf bytes.Buffer
@@ -104,12 +104,13 @@ func JobSend(cmd *exec.Cmd, data string) {
 // luaFunctionJob returns a function that will call the given lua function
 // structured as a job call i.e. the job output and arguments are provided
 // to the lua function
-func luaFunctionJob(fn string) func(string, ...string) {
+func luaFunctionJob(fn string) func(string, ...interface{}) {
        luaFn := strings.Split(fn, ".")
        plName, plFn := luaFn[0], luaFn[1]
        pl := config.FindPlugin(plName)
-       return func(output string, args ...string) {
+       return func(output string, args ...interface{}) {
                var luaArgs []lua.LValue
+               luaArgs = append(luaArgs, luar.New(ulua.L, output))
                for _, v := range args {
                        luaArgs = append(luaArgs, luar.New(ulua.L, v))
                }
@@ -119,11 +120,3 @@ func luaFunctionJob(fn string) func(string, ...string) {
                }
        }
 }
-
-func unpack(old []string) []interface{} {
-       new := make([]interface{}, len(old))
-       for i, v := range old {
-               new[i] = v
-       }
-       return new
-}
index bdcf11eef471bd7e0a7cca38d2b1276340a80b34..280c6caed6da547126126852478acc98c2b13de5 100644 (file)
@@ -3,6 +3,7 @@ package util
 import (
        "errors"
        "fmt"
+       "log"
        "os"
        "os/user"
        "path/filepath"
@@ -202,10 +203,10 @@ func FSize(f *os.File) int64 {
 }
 
 // IsWordChar returns whether or not the string is a 'word character'
-// If it is a unicode character, then it does not match
-// Word characters are defined as [A-Za-z0-9_]
+// Word characters are defined as numbers, letters, or '_'
 func IsWordChar(r rune) bool {
-       return (r >= '0' && r <= '9') || (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || (r == '_')
+       log.Println("IsWordChar")
+       return unicode.IsLetter(r) || unicode.IsNumber(r) || r == '_'
 }
 
 // Spaces returns a string with n spaces
@@ -237,7 +238,7 @@ func IsSpacesOrTabs(str []byte) bool {
 
 // IsWhitespace returns true if the given rune is a space, tab, or newline
 func IsWhitespace(c rune) bool {
-       return c == ' ' || c == '\t' || c == '\n'
+       return unicode.IsSpace(c)
 }
 
 // IsBytesWhitespace returns true if the given bytes are all whitespace
index e1ec97732a2ae4d7e5bdf7570780fb1ba9171fcb..46be745bfd54a360518488177e4536af2306a87d 100644 (file)
-if GetOption("linter") == nil then
-    AddOption("linter", true)
-end
+local runtime = import("runtime")
+local filepath = import("path/filepath")
+local shell = import("micro/shell")
+local buffer = import("micro/buffer")
+local micro = import("micro")
 
-MakeCommand("lint", "linter.lintCommand", 0)
+local linters = {}
 
-function lintCommand()
-    CurView():Save(false)
-    runLinter()
+-- creates a linter entry, call from within an initialization function, not
+-- directly at initial load time
+--
+-- name: name of the linter
+-- filetype: filetype to check for to use linter
+-- cmd: main linter process that is executed
+-- args: arguments to pass to the linter process
+--     use %f to refer to the current file name
+--     use %d to refer to the current directory name
+-- errorformat: how to parse the linter/compiler process output
+--     %f: file, %l: line number, %m: error/warning message
+-- os: list of OSs this linter is supported or unsupported on
+--     optional param, default: []
+-- whitelist: should the OS list be a blacklist (do not run the linter for these OSs)
+-- or a whitelist (only run the linter for these OSs)
+--     optional param, default: false (should blacklist)
+-- domatch: should the filetype be interpreted as a lua pattern to match with
+-- the actual filetype, or should the linter only activate on an exact match
+--     optional param, default: false (require exact match)
+function makeLinter(name, filetype, cmd, args, errorformat, os, whitelist, domatch)
+    if linters[name] == nil then
+        linters[name] = {}
+        linters[name].filetype = filetype
+        linters[name].cmd = cmd
+        linters[name].args = args
+        linters[name].errorformat = errorformat
+        linters[name].os = os or {}
+        linters[name].whitelist = whitelist or false
+        linters[name].domatch = domatch or false
+    end
 end
 
-function runLinter()
-    local ft = CurView().Buf:FileType()
-    local file = CurView().Buf.Path
-    local dir = DirectoryName(file)
-    if OS == "windows" then
+function removeLinter(name)
+    linters[name] = nil
+end
+
+function init()
+    local devnull = "/dev/null"
+    if runtime.GOOS == "windows" then
         devnull = "NUL"
-    else
-        devnull = "/dev/null"
     end
 
-    if ft == "c" then
-        lint("gcc", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
-    elseif ft == "c++" then
-        lint("gcc", "gcc", {"-fsyntax-only","-std=c++14", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
-    elseif ft == "d" then
-        lint("dmd", "dmd", {"-color=off", "-o-", "-w", "-wi", "-c", file}, "%f%(%l%):.+: %m")
-    elseif ft == "go" then
-        lint("gobuild", "go", {"build", "-o", devnull}, "%f:%l: %m")
-        lint("golint", "golint", {file}, "%f:%l:%d+: %m")
-    elseif ft == "java" then
-        lint("javac", "javac", {"-d", dir, file}, "%f:%l: error: %m")
-    elseif ft == "javascript" then
-        lint("jshint", "jshint", {file}, "%f: line %l,.+, %m")
-    elseif string.match(ft, "literate") then
-        lint("literate", "lit", {"-c", file}, "%f:%l:%m")
-    elseif ft == "lua" then
-        lint("luacheck", "luacheck", {"--no-color", file}, "%f:%l:%d+: %m")
-    elseif ft == "nim" then
-        lint("nim", "nim", {"check", "--listFullPaths", "--stdout", "--hints:off", file}, "%f.%l, %d+. %m")
-    elseif ft == "Objective-C" then
-        lint("clang", "xcrun", {"clang", "-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
-    elseif ft == "python" then
-        lint("pyflakes", "pyflakes", {file}, "%f:%l:.-:? %m")
-        lint("mypy", "mypy", {file}, "%f:%l: %m")
-        lint("pylint", "pylint", {"--output-format=parseable", "--reports=no", file}, "%f:%l: %m")
-    elseif ft == "shell" then
-        lint("shfmt", "shfmt", {file}, "%f:%l:%d+: %m")
-    elseif ft == "swift" and OS == "darwin" then
-        lint("switfc", "xcrun", {"swiftc", file}, "%f:%l:%d+:.+: %m")
-    elseif ft == "swift" and OS == "linux" then
-        lint("switfc", "swiftc", {file}, "%f:%l:%d+:.+: %m")
-    elseif ft == "yaml" then
-        lint("yaml", "yamllint", {"--format", "parsable", file}, "%f:%l:%d+:.+ %m")
+    makeLinter("gcc", "c", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", "%f"}, "%f:%l:%d+:.+: %m")
+    makeLinter("gcc", "c++", "gcc", {"-fsyntax-only","-std=c++14", "-Wall", "-Wextra", "%f"}, "%f:%l:%d+:.+: %m")
+    makeLinter("dmd", "d", "dmd", {"-color=off", "-o-", "-w", "-wi", "-c", "%f"}, "%f%(%l%):.+: %m")
+    makeLinter("gobuild", "go", "go", {"build", "-o", devnull}, "%f:%l: %m")
+    makeLinter("golint", "go", "golint", {"%f"}, "%f:%l:%d+: %m")
+    makeLinter("javac", "java", "javac", {"-d", "%d", "%f"}, "%f:%l: error: %m")
+    makeLinter("jshint", "javascript", "jshint", {"%f"}, "%f: line %l,.+, %m")
+    makeLinter("literate", "literate", "lit", {"-c", "%f"}, "%f:%l:%m", {}, false, true)
+    makeLinter("luacheck", "lua", "luacheck", {"--no-color", "%f"}, "%f:%l:%d+: %m")
+    makeLinter("nim", "nim", "nim", {"check", "--listFullPaths", "--stdout", "--hints:off", "%f"}, "%f.%l, %d+. %m")
+    makeLinter("clang", "objective-c", "xcrun", {"clang", "-fsyntax-only", "-Wall", "-Wextra", "%f"}, "%f:%l:%d+:.+: %m")
+    makeLinter("pyflakes", "python", "pyflakes", {"%f"}, "%f:%l:.-:? %m")
+    makeLinter("mypy", "python", "mypy", {"%f"}, "%f:%l: %m")
+    makeLinter("pylint", "python", "pylint", {"--output-format=parseable", "--reports=no", "%f"}, "%f:%l: %m")
+    makeLinter("shfmt", "shell", "shfmt", {"%f"}, "%f:%l:%d+: %m")
+    makeLinter("switfc", "swift", "xcrun", {"swiftc", "%f"}, "%f:%l:%d+:.+: %m", {"darwin"}, true)
+    makeLinter("switfc", "swiftc", {"%f"}, "%f:%l:%d+:.+: %m", {"linux"}, true)
+    makeLinter("yaml", "yaml", "yamllint", {"--format", "parsable", "%f"}, "%f:%l:%d+:.+ %m")
+end
+
+function contains(list, element)
+    for k, v in pairs(list) do
+        if v == element then
+            return true
+        end
     end
+    return false
 end
 
-function onSave(view)
-    if GetOption("linter") then
-        runLinter()
-    else
-        CurView():ClearAllGutterMessages()
+function runLinter(buf)
+    local ft = buf:FileType()
+    local file = buf.Path
+    local dir = filepath.Dir(file)
+
+    for k, v in pairs(linters) do
+        local ftmatch = ft == v.filetype
+        if v.domatch then
+            ftmatch = string.match(ft, v.filetype)
+        end
+
+        local hasOS = contains(v.os, runtime.GOOS)
+        if not hasOS and v.whitelist then
+            ftmatch = false
+        end
+        if hasOS and not v.whitelist then
+            ftmatch = false
+        end
+
+        for k, arg in pairs(v.args) do
+            v.args[k] = arg:gsub("%%f", file):gsub("%%d", dir)
+        end
+
+        if ftmatch then
+            lint(buf, k, v.cmd, v.args, v.errorformat)
+        end
     end
 end
 
-function lint(linter, cmd, args, errorformat)
-    CurView():ClearGutterMessages(linter)
+function onSave(bp)
+    micro.Log("SAVE")
+    runLinter(bp.Buf)
+    return false
+end
+
+function lint(buf, linter, cmd, args, errorformat)
+    buf:ClearMessages("linter")
 
-    JobSpawn(cmd, args, "", "", "linter.onExit", linter, errorformat)
+    shell.JobSpawn(cmd, args, "", "", "linter.onExit", buf, linter, errorformat)
 end
 
-function onExit(output, linter, errorformat)
+function onExit(output, buf, linter, errorformat)
+    micro.Log("ONEXIT")
+    micro.Log(output)
     local lines = split(output, "\n")
 
     local regex = errorformat:gsub("%%f", "(..-)"):gsub("%%l", "(%d+)"):gsub("%%m", "(.+)")
@@ -78,8 +129,9 @@ function onExit(output, linter, errorformat)
         line = line:match("^%s*(.+)%s*$")
         if string.find(line, regex) then
             local file, line, msg = string.match(line, regex)
-            if basename(CurView().Buf.Path) == basename(file) then
-                CurView():GutterMessage(linter, tonumber(line), msg, 2)
+            if basename(buf.Path) == basename(file) then
+                local bmsg = buffer.NewMessageAtLine("linter", msg, tonumber(line), buffer.MTError)
+                buf:AddMessage(bmsg)
             end
         end
     end
@@ -96,7 +148,7 @@ end
 
 function basename(file)
     local sep = "/"
-    if OS == "windows" then
+    if runtime.GOOS == "windows" then
         sep = "\\"
     end
     local name = string.gsub(file, "(.*" .. sep .. ")(.*)", "%2")