diff --git a/src/margo.sh/Gopkg.lock b/src/margo.sh/Gopkg.lock index de10f658..8c58e411 100644 --- a/src/margo.sh/Gopkg.lock +++ b/src/margo.sh/Gopkg.lock @@ -17,17 +17,39 @@ branch = "master" name = "golang.org/x/crypto" packages = ["blake2b"] - revision = "2c241ca3045ddc354463c376a9515d9f1f1390a4" + revision = "4ec37c66abab2c7e02ae775328b2ff001c3f025a" [[projects]] branch = "master" name = "golang.org/x/sys" packages = ["cpu"] - revision = "78d5f264b493f125018180c204871ecf58a2dce1" + revision = "7db1c3b1a98089d0071c84f646ff5c96aad43682" + +[[projects]] + branch = "master" + name = "golang.org/x/tools" + packages = [ + "cmd/guru", + "cmd/guru/serial", + "container/intsets", + "go/ast/astutil", + "go/buildutil", + "go/callgraph", + "go/callgraph/static", + "go/loader", + "go/pointer", + "go/ssa", + "go/ssa/ssautil", + "go/types/typeutil", + "imports", + "internal/fastwalk", + "refactor/importgraph" + ] + revision = "87723262609ca8fd55d449c027454c29cadefd68" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "a7d8a00d2d704fb62eed79ee67536c295268edae7c67b316af3af70397acad95" + inputs-digest = "d929fab6918d1833fd0bf96d285bc438bfa936590205bbba2e182511b2bf6ac5" solver-name = "gps-cdcl" solver-version = 1 diff --git a/src/margo.sh/Gopkg.toml b/src/margo.sh/Gopkg.toml index 48f5c2eb..9d2cfa57 100644 --- a/src/margo.sh/Gopkg.toml +++ b/src/margo.sh/Gopkg.toml @@ -1,3 +1,11 @@ +required = [ + "golang.org/x/tools/cmd/guru" +] + +[prune] + go-tests = true + unused-packages = true + [[constraint]] name = "github.com/ugorji/go" branch = "master" @@ -10,6 +18,6 @@ branch = "master" name = "golang.org/x/crypto" -[prune] - go-tests = true - unused-packages = true +[[constraint]] + branch = "master" + name = "golang.org/x/tools" diff --git a/src/margo.sh/cmdpkg/margosublime/main.go b/src/margo.sh/cmdpkg/margosublime/main.go index 90644935..9041a7c2 100644 --- a/src/margo.sh/cmdpkg/margosublime/main.go +++ b/src/margo.sh/cmdpkg/margosublime/main.go @@ -33,7 +33,7 @@ func Main() { return mgcli.Error("agent creation failed:", err) } - ag.Store.EditorConfig(sublime.DefaultConfig) + ag.Store.SetBaseConfig(sublime.DefaultConfig) if margoExt != nil { margoExt(ag.Args()) } diff --git a/src/margo.sh/extension-example/extension-example.go b/src/margo.sh/extension-example/extension-example.go index 860aaba4..9d89e3b0 100644 --- a/src/margo.sh/extension-example/extension-example.go +++ b/src/margo.sh/extension-example/extension-example.go @@ -12,12 +12,12 @@ func Margo(ma mg.Args) { // they are run in the specified order // and should ideally not block for more than a couple milliseconds ma.Store.Use( - // by default, events (e.g. ViewSaved) are triggered in all files - // uncomment the reducer below to restict event to Go(-lang) files - // please note, however, that this mode is not tested + // By default, events (e.g. ViewSaved) are triggered in all files. + // Uncomment the reducer below to restict events to Go(-lang) files. + // Please note, however, that this mode is not tested // and saving a non-go file will not trigger linters, etc. for that go pkg // - // mg.Reduce(func(mx *mg.Ctx) *mg.State { + // mg.NewReducer(func(mx *mg.Ctx) *mg.State { // return mx.SetConfig(mx.Config.EnabledForLangs("go")) // }), diff --git a/src/margo.sh/format/format.go b/src/margo.sh/format/format.go index b2bd1226..2520cec2 100644 --- a/src/margo.sh/format/format.go +++ b/src/margo.sh/format/format.go @@ -19,22 +19,20 @@ type FmtFunc struct { Fmt func(mx *mg.Ctx, src []byte) ([]byte, error) // Langs is the list of languages in which the reducer should run - Langs []string + Langs []mg.Lang - // Actions is a list of additional actions on which the reducer is allowed to run. + // Actions is a list of actions on which the reducer is allowed to run. // The reducer always runs on the ViewFmt action, even if this list is empty. Actions []mg.Action } +// ReducerCond returns true if Langs and Actions matches the Ctx +func (ff FmtFunc) ReducerCond(mx *mg.Ctx) bool { + return mx.ActionIs(ff.Actions...) && mx.LangIs(ff.Langs...) +} + // Reduce implements the FmtFunc reducer. func (ff FmtFunc) Reduce(mx *mg.Ctx) *mg.State { - if !mx.LangIs(ff.Langs...) { - return mx.State - } - if !mx.ActionIs(mg.ViewFmt{}) && !mx.ActionIs(ff.Actions...) { - return mx.State - } - fn := mx.View.Filename() src, err := mx.View.ReadAll() if err != nil { @@ -48,7 +46,7 @@ func (ff FmtFunc) Reduce(mx *mg.Ctx) *mg.State { if err != nil { return mx.AddErrorf("failed to fmt %s: %s\n", fn, err) } - return mx.SetSrc(src) + return mx.SetViewSrc(src) } // FmtCmd is wrapper around FmtFunc for generic fmt commands. @@ -66,9 +64,9 @@ type FmtCmd struct { Env mg.EnvMap // Langs is the list of languages in which the reducer should run - Langs []string + Langs []mg.Lang - // Actions is a list of additional actions on which the reducer is allowed to run. + // Actions is a list of actions on which the reducer is allowed to run. // The reducer always runs on the ViewFmt action, even if this list is empty. Actions []mg.Action } diff --git a/src/margo.sh/golang/common.go b/src/margo.sh/golang/common.go index bff089b6..e2925a9c 100644 --- a/src/margo.sh/golang/common.go +++ b/src/margo.sh/golang/common.go @@ -1,10 +1,10 @@ package golang import ( - "margo.sh/mg" "go/ast" "go/build" "go/token" + "margo.sh/mg" "os" "path/filepath" "reflect" @@ -14,12 +14,12 @@ import ( "unicode/utf8" ) -var ( - CommonPatterns = append([]*regexp.Regexp{ +func init() { + mg.AddCommonPatterns(mg.Go, regexp.MustCompile(`^\s*(?P.+?\.\w+):(?P\d+:)(?P\d+:?)?(?:(?Pwarning|error)[:])?(?P.+?)(?: [(](?P