Compare commits

..

12 Commits

Author SHA1 Message Date
Zachary Yedidia
fb258dd57a Clean default settings in micro -clean 2020-06-18 17:22:21 -04:00
Zachary Yedidia
891b117a33 Bind Ctrl-/ (CtrlUnderscore) in comment plugin 2020-06-18 17:18:34 -04:00
Zachary Yedidia
f5dc0a51ba Fix issue with search and replace at the end of a range 2020-06-18 16:38:10 -04:00
Zachary Yedidia
8cbe7fa92b Update tcell version 2020-06-17 23:24:53 -04:00
Zachary Yedidia
a584ff36de Merge 2020-06-17 23:14:03 -04:00
Zachary Yedidia
f5405cee18 Improve keybinding label consistency
The old notation (for example `CtrlG`) causes confusion when combined
with new notation needed for alt (`Alt-g`) due to Alt being case
sensitive. Previously both formats were supported, but the documentation
and defaults used a combination. This commit only uses the new notation
for consistency.

Ref #1470
2020-06-17 23:11:50 -04:00
Zachary Yedidia
3516c8a9a6 Start replacement search at cursor location
Fixes #1731
2020-06-17 22:43:22 -04:00
Matthias
c19dce87e4 Fix typo in defaultkeys (#1730) 2020-06-17 13:35:59 -04:00
Zachary Yedidia
2adba18159 Don't move nightly tag 2020-06-17 00:48:17 +00:00
Zachary Yedidia
f9f2ef02ac Edit nightly release instead of replacing 2020-06-16 20:33:59 -04:00
Zachary Yedidia
0976eb3e51 Cross compile binaries in release scripts 2020-06-16 19:55:12 -04:00
Zachary Yedidia
ac2d1491ff Use hub for creating releases 2020-06-16 19:55:12 -04:00
30 changed files with 7877 additions and 994 deletions

1
.gitignore vendored
View File

@@ -18,4 +18,3 @@ tools/info-plist
tools/bindata
tools/vscode-tests/
*.hdr
assets_vfsdata.go

3
.gitmodules vendored
View File

@@ -0,0 +1,3 @@
[submodule "tools/go-bindata"]
path = tools/go-bindata
url = https://github.com/zyedidia/go-bindata

View File

@@ -45,7 +45,13 @@ fetch-tags:
# Builds the runtime
runtime:
go generate ./internal/config
git submodule update --init
rm -f runtime/syntax/*.hdr
go run runtime/syntax/make_headers.go runtime/syntax
go build -o tools/bindata ./tools/go-bindata
tools/bindata -pkg config -nomemcopy -nometadata -o runtime.go runtime/...
mv runtime.go internal/config
gofmt -w internal/config/runtime.go
testgen:
mkdir -p tools/vscode-tests

View File

@@ -41,6 +41,9 @@ func CleanConfig() {
return
}
fmt.Println("Cleaning default settings")
config.WriteSettings(filepath.Join(config.ConfigDir, "settings.json"))
// detect unused options
var unusedOptions []string
defaultSettings := config.DefaultAllSettings()

5
go.mod
View File

@@ -10,8 +10,6 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff
github.com/sergi/go-diff v1.1.0
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd // indirect
github.com/stretchr/testify v1.4.0
github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb
github.com/zyedidia/clipboard v0.0.0-20200421031010-7c45b8673834
@@ -19,10 +17,9 @@ require (
github.com/zyedidia/highlight v0.0.0-20170330143449-201131ce5cf5
github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d
github.com/zyedidia/pty v2.0.0+incompatible // indirect
github.com/zyedidia/tcell v1.4.6
github.com/zyedidia/tcell v1.4.7
github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415
golang.org/x/text v0.3.2
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.2.7
layeh.com/gopher-luar v1.0.7

9
go.sum
View File

@@ -31,10 +31,6 @@ github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff h1:+6NUiITWwE5q1
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd h1:ug7PpSOB5RBPK1Kg6qskGBoP3Vnj/aNYFTznWvlkGo0=
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
@@ -56,8 +52,8 @@ github.com/zyedidia/poller v1.0.1 h1:Tt9S3AxAjXwWGNiC2TUdRJkQDZSzCBNVQ4xXiQ7440s
github.com/zyedidia/poller v1.0.1/go.mod h1:vZXJOHGDcuK08GXhF6IAY0ZFd2WcgOR5DOTp84Uk5eE=
github.com/zyedidia/pty v2.0.0+incompatible h1:Ou5vXL6tvjst+RV8sUFISbuKDnUJPhnpygApMFGweqw=
github.com/zyedidia/pty v2.0.0+incompatible/go.mod h1:4y9l9yJZNxRa7GB/fB+mmDmGkG3CqmzLf4vUxGGotEA=
github.com/zyedidia/tcell v1.4.6 h1:8OYvZpUyqYQ3nigenBwOtnY3fXWEHekbm6QYchBeOxs=
github.com/zyedidia/tcell v1.4.6/go.mod h1:HhlbMSCcGX15rFDB+Q1Lk3pKEOocsCUAQC3zhZ9sadA=
github.com/zyedidia/tcell v1.4.7 h1:bKXRjv8RglPyOFqofzUUJkrdsLs9p9mT89W2ShFFlco=
github.com/zyedidia/tcell v1.4.7/go.mod h1:HhlbMSCcGX15rFDB+Q1Lk3pKEOocsCUAQC3zhZ9sadA=
github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415 h1:752dTQ5OatJ9M5ULK2+9lor+nzyZz+LYDo3WGngg3Rc=
github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415/go.mod h1:8leT8G0Cm8NoJHdrrKHyR9MirWoF4YW7pZh06B6H+1E=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -67,7 +63,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=

View File

@@ -805,7 +805,7 @@ func (h *BufPane) ReplaceCmd(args []string) {
return l.GreaterEqual(start) && l.LessEqual(end)
}
searchLoc := start
searchLoc := h.Cursor.Loc
var doReplacement func()
doReplacement = func() {
locs, found, err := h.Buf.FindNext(search, start, end, searchLoc, true, !noRegex)
@@ -816,6 +816,7 @@ func (h *BufPane) ReplaceCmd(args []string) {
if !found || !inRange(locs[0]) || !inRange(locs[1]) {
h.Cursor.ResetSelection()
h.Buf.RelocateCursors()
return
}
@@ -831,7 +832,9 @@ func (h *BufPane) ReplaceCmd(args []string) {
searchLoc = locs[0]
searchLoc.X += nrunes + locs[0].Diff(locs[1], h.Buf)
end.Move(nrunes, h.Buf)
if end.Y == locs[1].Y {
end = end.Move(nrunes, h.Buf)
}
h.Cursor.Loc = searchLoc
nreplaced++
} else if !canceled && !yes {

View File

@@ -30,28 +30,28 @@ func DefaultBindings() map[string]string {
"Alt-{": "ParagraphPrevious",
"Alt-}": "ParagraphNext",
"Enter": "InsertNewline",
"CtrlH": "Backspace",
"Ctrl-h": "Backspace",
"Backspace": "Backspace",
"Alt-CtrlH": "DeleteWordLeft",
"Alt-Backspace": "DeleteWordLeft",
"Tab": "Autocomplete|IndentSelection|InsertTab",
"Backtab": "CycleAutocompleteBack|OutdentSelection|OutdentLine",
"CtrlO": "OpenFile",
"CtrlS": "Save",
"CtrlF": "Find",
"CtrlN": "FindNext",
"CtrlP": "FindPrevious",
"CtrlZ": "Undo",
"CtrlY": "Redo",
"CtrlC": "CopyLine|Copy",
"CtrlX": "Cut",
"CtrlK": "CutLine",
"CtrlD": "DuplicateLine",
"CtrlV": "Paste",
"CtrlA": "SelectAll",
"CtrlT": "AddTab",
"Alt,": "PreviousTab",
"Alt.": "NextTab",
"Ctrl-o": "OpenFile",
"Ctrl-s": "Save",
"Ctrl-f": "Find",
"Ctrl-n": "FindNext",
"Ctrl-p": "FindPrevious",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-k": "CutLine",
"Ctrl-d": "DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
"Ctrl-t": "AddTab",
"Alt-,": "PreviousTab",
"Alt-.": "NextTab",
"Home": "StartOfTextToggle",
"End": "EndOfLine",
"CtrlHome": "CursorStart",
@@ -60,17 +60,17 @@ func DefaultBindings() map[string]string {
"PageDown": "CursorPageDown",
"CtrlPageUp": "PreviousTab",
"CtrlPageDown": "NextTab",
"CtrlG": "ToggleHelp",
"Ctrl-g": "ToggleHelp",
"Alt-g": "ToggleKeyMenu",
"CtrlR": "ToggleRuler",
"CtrlL": "command-edit:goto ",
"Ctrl-r": "ToggleRuler",
"Ctrl-l": "command-edit:goto ",
"Delete": "Delete",
"CtrlB": "ShellMode",
"CtrlQ": "Quit",
"CtrlE": "CommandMode",
"CtrlW": "NextSplit",
"CtrlU": "ToggleMacro",
"CtrlJ": "PlayMacro",
"Ctrl-b": "ShellMode",
"Ctrl-q": "Quit",
"Ctrl-e": "CommandMode",
"Ctrl-w": "NextSplit",
"Ctrl-u": "ToggleMacro",
"Ctrl-j": "PlayMacro",
"Insert": "ToggleOverwriteMode",
// Emacs-style keybindings

View File

@@ -32,28 +32,28 @@ func DefaultBindings() map[string]string {
"Alt-{": "ParagraphPrevious",
"Alt-}": "ParagraphNext",
"Enter": "InsertNewline",
"CtrlH": "Backspace",
"Ctrl-h": "Backspace",
"Backspace": "Backspace",
"Alt-CtrlH": "DeleteWordLeft",
"Alt-Backspace": "DeleteWordLeft",
"Tab": "Autocomplete|IndentSelection|InsertTab",
"Backtab": "CycleAutocompleteBack|OutdentSelection|OutdentLine",
"CtrlO": "OpenFile",
"CtrlS": "Save",
"CtrlF": "Find",
"CtrlN": "FindNext",
"CtrlP": "FindPrevious",
"CtrlZ": "Undo",
"CtrlY": "Redo",
"CtrlC": "CopyLine|Copy",
"CtrlX": "Cut",
"CtrlK": "CutLine",
"CtrlD": "DuplicateLine",
"CtrlV": "Paste",
"CtrlA": "SelectAll",
"CtrlT": "AddTab",
"Alt,": "PreviousTab",
"Alt.": "NextTab",
"Ctrl-o": "OpenFile",
"Ctrl-s": "Save",
"Ctrl-f": "Find",
"Ctrl-n": "FindNext",
"Ctrl-p": "FindPrevious",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-k": "CutLine",
"Ctrl-d": "DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
"Ctrl-t": "AddTab",
"Alt-,": "PreviousTab",
"Alt-.": "NextTab",
"Home": "StartOfTextToggle",
"End": "EndOfLine",
"CtrlHome": "CursorStart",
@@ -62,17 +62,17 @@ func DefaultBindings() map[string]string {
"PageDown": "CursorPageDown",
"CtrlPageUp": "PreviousTab",
"CtrlPageDown": "NextTab",
"CtrlG": "ToggleHelp",
"Ctrl-g": "ToggleHelp",
"Alt-g": "ToggleKeyMenu",
"CtrlR": "ToggleRuler",
"CtrlL": "command-edit:goto ",
"Ctrl-r": "ToggleRuler",
"Ctrl-l": "command-edit:goto ",
"Delete": "Delete",
"CtrlB": "ShellMode",
"CtrlQ": "Quit",
"CtrlE": "CommandMode",
"CtrlW": "NextSplit",
"CtrlU": "ToggleMacro",
"CtrlJ": "PlayMacro",
"Ctrl-b": "ShellMode",
"Ctrl-q": "Quit",
"Ctrl-e": "CommandMode",
"Ctrl-w": "NextSplit",
"Ctrl-u": "ToggleMacro",
"Ctrl-j": "PlayMacro",
"Insert": "ToggleOverwriteMode",
// Emacs-style keybindings

View File

@@ -7,6 +7,13 @@ import (
)
func (b *Buffer) findDown(r *regexp.Regexp, start, end Loc) ([2]Loc, bool) {
lastcn := util.CharacterCount(b.LineBytes(b.LinesNum() - 1))
if start.Y > b.LinesNum()-1 {
start.X = lastcn - 1
}
if end.Y > b.LinesNum()-1 {
end.X = lastcn
}
start.Y = util.Clamp(start.Y, 0, b.LinesNum()-1)
end.Y = util.Clamp(end.Y, 0, b.LinesNum()-1)
@@ -48,6 +55,13 @@ func (b *Buffer) findDown(r *regexp.Regexp, start, end Loc) ([2]Loc, bool) {
}
func (b *Buffer) findUp(r *regexp.Regexp, start, end Loc) ([2]Loc, bool) {
lastcn := util.CharacterCount(b.LineBytes(b.LinesNum() - 1))
if start.Y > b.LinesNum()-1 {
start.X = lastcn - 1
}
if end.Y > b.LinesNum()-1 {
end.X = lastcn
}
start.Y = util.Clamp(start.Y, 0, b.LinesNum()-1)
end.Y = util.Clamp(end.Y, 0, b.LinesNum()-1)
@@ -132,7 +146,7 @@ func (b *Buffer) FindNext(s string, start, end, from Loc, down bool, useRegex bo
// ReplaceRegex replaces all occurrences of 'search' with 'replace' in the given area
// and returns the number of replacements made and the number of runes
// added or removed
// added or removed on the last line of the range
func (b *Buffer) ReplaceRegex(start, end Loc, search *regexp.Regexp, replace []byte) (int, int) {
if start.GreaterThan(end) {
start, end = end, start
@@ -162,7 +176,9 @@ func (b *Buffer) ReplaceRegex(start, end Loc, search *regexp.Regexp, replace []b
result = search.Expand(result, replace, in, submatches)
}
found++
netrunes += util.CharacterCount(in) - util.CharacterCount(result)
if i == end.Y {
netrunes += util.CharacterCount(result) - util.CharacterCount(in)
}
return result
})

View File

@@ -1,4 +1,3 @@
//go:generate go run runtime_generate.go ../../runtime/syntax ../../runtime
package config
import (
@@ -10,8 +9,6 @@ import (
"path/filepath"
"regexp"
"strings"
"github.com/zyedidia/micro/v2/internal/vfsutil"
)
const (
@@ -93,7 +90,7 @@ func (af assetFile) Name() string {
}
func (af assetFile) Data() ([]byte, error) {
return vfsutil.ReadFile(Assets, string(af))
return Asset(string(af))
}
func (nf namedFile) Name() string {
@@ -114,10 +111,7 @@ func AddRealRuntimeFile(fileType RTFiletype, file RuntimeFile) {
// AddRuntimeFilesFromDirectory registers each file from the given directory for
// the filetype which matches the file-pattern
func AddRuntimeFilesFromDirectory(fileType RTFiletype, directory, pattern string) {
files, err := ioutil.ReadDir(directory)
if err != nil {
return
}
files, _ := ioutil.ReadDir(directory)
for _, f := range files {
if ok, _ := filepath.Match(pattern, f.Name()); !f.IsDir() && ok {
fullPath := filepath.Join(directory, f.Name())
@@ -129,13 +123,13 @@ func AddRuntimeFilesFromDirectory(fileType RTFiletype, directory, pattern string
// AddRuntimeFilesFromAssets registers each file from the given asset-directory for
// the filetype which matches the file-pattern
func AddRuntimeFilesFromAssets(fileType RTFiletype, directory, pattern string) {
files, err := vfsutil.ReadDir(Assets, directory)
files, err := AssetDir(directory)
if err != nil {
return
}
for _, f := range files {
if ok, _ := path.Match(pattern, f.Name()); ok {
AddRuntimeFile(fileType, assetFile(path.Join(directory, f.Name())))
if ok, _ := path.Match(pattern, f); ok {
AddRuntimeFile(fileType, assetFile(path.Join(directory, f)))
}
}
}
@@ -162,60 +156,11 @@ func ListRealRuntimeFiles(fileType RTFiletype) []RuntimeFile {
return realFiles[fileType]
}
func addPlugin(dirname string, plugdir string, isID func(string) bool, vfs bool) {
var srcs []os.FileInfo
var err error
if vfs {
srcs, err = vfsutil.ReadDir(Assets, filepath.Join(plugdir, dirname))
} else {
srcs, err = ioutil.ReadDir(filepath.Join(plugdir, dirname))
}
if err != nil {
return
}
p := new(Plugin)
p.Name = dirname
p.DirName = dirname
p.Default = vfs
for _, f := range srcs {
if strings.HasSuffix(f.Name(), ".lua") {
if vfs {
p.Srcs = append(p.Srcs, assetFile(filepath.Join(plugdir, dirname, f.Name())))
} else {
p.Srcs = append(p.Srcs, realFile(filepath.Join(plugdir, dirname, f.Name())))
}
} else if strings.HasSuffix(f.Name(), ".json") {
var data []byte
var err error
if vfs {
data, err = vfsutil.ReadFile(Assets, filepath.Join(plugdir, dirname, f.Name()))
} else {
data, err = ioutil.ReadFile(filepath.Join(plugdir, dirname, f.Name()))
}
if err != nil {
continue
}
p.Info, err = NewPluginInfo(data)
if err != nil {
continue
}
p.Name = p.Info.Name
}
}
if !isID(p.Name) || len(p.Srcs) <= 0 {
log.Println(p.Name, "is not a plugin")
return
}
Plugins = append(Plugins, p)
}
// InitRuntimeFiles initializes all assets file and the config directory
func InitRuntimeFiles() {
add := func(fileType RTFiletype, dir, pattern string) {
AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern)
AddRuntimeFilesFromAssets(fileType, dir, pattern)
AddRuntimeFilesFromAssets(fileType, path.Join("runtime", dir), pattern)
}
add(RTColorscheme, "colorschemes", "*.micro")
@@ -234,24 +179,68 @@ func InitRuntimeFiles() {
// Search ConfigDir for plugin-scripts
plugdir := filepath.Join(ConfigDir, "plug")
files, err := ioutil.ReadDir(plugdir)
files, _ := ioutil.ReadDir(plugdir)
isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString
if err == nil {
for _, d := range files {
if d.IsDir() {
addPlugin(d.Name(), plugdir, isID, false)
for _, d := range files {
if d.IsDir() {
srcs, _ := ioutil.ReadDir(filepath.Join(plugdir, d.Name()))
p := new(Plugin)
p.Name = d.Name()
p.DirName = d.Name()
for _, f := range srcs {
if strings.HasSuffix(f.Name(), ".lua") {
p.Srcs = append(p.Srcs, realFile(filepath.Join(plugdir, d.Name(), f.Name())))
} else if strings.HasSuffix(f.Name(), ".json") {
data, err := ioutil.ReadFile(filepath.Join(plugdir, d.Name(), f.Name()))
if err != nil {
continue
}
p.Info, err = NewPluginInfo(data)
if err != nil {
continue
}
p.Name = p.Info.Name
}
}
if !isID(p.Name) || len(p.Srcs) <= 0 {
log.Println(p.Name, "is not a plugin")
continue
}
Plugins = append(Plugins, p)
}
}
plugdir = "plugins"
files, err = vfsutil.ReadDir(Assets, plugdir)
if err == nil {
plugdir = filepath.Join("runtime", "plugins")
if files, err := AssetDir(plugdir); err == nil {
for _, d := range files {
if d.IsDir() {
addPlugin(d.Name(), plugdir, isID, true)
if srcs, err := AssetDir(filepath.Join(plugdir, d)); err == nil {
p := new(Plugin)
p.Name = d
p.DirName = d
p.Default = true
for _, f := range srcs {
if strings.HasSuffix(f, ".lua") {
p.Srcs = append(p.Srcs, assetFile(filepath.Join(plugdir, d, f)))
} else if strings.HasSuffix(f, ".json") {
data, err := Asset(filepath.Join(plugdir, d, f))
if err != nil {
continue
}
p.Info, err = NewPluginInfo(data)
if err != nil {
continue
}
p.Name = p.Info.Name
}
}
if !isID(p.Name) || len(p.Srcs) <= 0 {
log.Println(p.Name, "is not a plugin")
continue
}
Plugins = append(Plugins, p)
}
}
}
@@ -288,7 +277,7 @@ func PluginAddRuntimeFile(plugin string, filetype RTFiletype, filePath string) e
if _, err := os.Stat(fullpath); err == nil {
AddRealRuntimeFile(filetype, realFile(fullpath))
} else {
fullpath = path.Join("plugins", pldir, filePath)
fullpath = path.Join("runtime", "plugins", pldir, filePath)
AddRuntimeFile(filetype, assetFile(fullpath))
}
return nil
@@ -305,7 +294,7 @@ func PluginAddRuntimeFilesFromDirectory(plugin string, filetype RTFiletype, dire
if _, err := os.Stat(fullpath); err == nil {
AddRuntimeFilesFromDirectory(filetype, fullpath, pattern)
} else {
fullpath = path.Join("plugins", pldir, directory)
fullpath = path.Join("runtime", "plugins", pldir, directory)
AddRuntimeFilesFromAssets(filetype, fullpath, pattern)
}
return nil

7510
internal/config/runtime.go Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,21 +0,0 @@
package vfsutil
import (
"net/http"
"os"
)
// File implements http.FileSystem using the native file system restricted to a
// specific file served at root.
//
// While the FileSystem.Open method takes '/'-separated paths, a File's string
// value is a filename on the native file system, not a URL, so it is separated
// by filepath.Separator, which isn't necessarily '/'.
type File string
func (f File) Open(name string) (http.File, error) {
if name != "/" {
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
}
return os.Open(string(f))
}

View File

@@ -1,39 +0,0 @@
// Package vfsutil implements some I/O utility functions for http.FileSystem.
package vfsutil
import (
"io/ioutil"
"net/http"
"os"
)
// ReadDir reads the contents of the directory associated with file and
// returns a slice of FileInfo values in directory order.
func ReadDir(fs http.FileSystem, name string) ([]os.FileInfo, error) {
f, err := fs.Open(name)
if err != nil {
return nil, err
}
defer f.Close()
return f.Readdir(0)
}
// Stat returns the FileInfo structure describing file.
func Stat(fs http.FileSystem, name string) (os.FileInfo, error) {
f, err := fs.Open(name)
if err != nil {
return nil, err
}
defer f.Close()
return f.Stat()
}
// ReadFile reads the file named by path from fs and returns the contents.
func ReadFile(fs http.FileSystem, path string) ([]byte, error) {
rc, err := fs.Open(path)
if err != nil {
return nil, err
}
defer rc.Close()
return ioutil.ReadAll(rc)
}

View File

@@ -1,146 +0,0 @@
package vfsutil
import (
"io"
"net/http"
"os"
pathpkg "path"
"path/filepath"
"sort"
)
// Walk walks the filesystem rooted at root, calling walkFn for each file or
// directory in the filesystem, including root. All errors that arise visiting files
// and directories are filtered by walkFn. The files are walked in lexical
// order.
func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error {
info, err := Stat(fs, root)
if err != nil {
return walkFn(root, nil, err)
}
return walk(fs, root, info, walkFn)
}
// readDirNames reads the directory named by dirname and returns
// a sorted list of directory entries.
func readDirNames(fs http.FileSystem, dirname string) ([]string, error) {
fis, err := ReadDir(fs, dirname)
if err != nil {
return nil, err
}
names := make([]string, len(fis))
for i := range fis {
names[i] = fis[i].Name()
}
sort.Strings(names)
return names, nil
}
// walk recursively descends path, calling walkFn.
func walk(fs http.FileSystem, path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
err := walkFn(path, info, nil)
if err != nil {
if info.IsDir() && err == filepath.SkipDir {
return nil
}
return err
}
if !info.IsDir() {
return nil
}
names, err := readDirNames(fs, path)
if err != nil {
return walkFn(path, info, err)
}
for _, name := range names {
filename := pathpkg.Join(path, name)
fileInfo, err := Stat(fs, filename)
if err != nil {
if err := walkFn(filename, fileInfo, err); err != nil && err != filepath.SkipDir {
return err
}
} else {
err = walk(fs, filename, fileInfo, walkFn)
if err != nil {
if !fileInfo.IsDir() || err != filepath.SkipDir {
return err
}
}
}
}
return nil
}
// WalkFilesFunc is the type of the function called for each file or directory visited by WalkFiles.
// It's like filepath.WalkFunc, except it provides an additional ReadSeeker parameter for file being visited.
type WalkFilesFunc func(path string, info os.FileInfo, rs io.ReadSeeker, err error) error
// WalkFiles walks the filesystem rooted at root, calling walkFn for each file or
// directory in the filesystem, including root. In addition to FileInfo, it passes an
// ReadSeeker to walkFn for each file it visits.
func WalkFiles(fs http.FileSystem, root string, walkFn WalkFilesFunc) error {
file, info, err := openStat(fs, root)
if err != nil {
return walkFn(root, nil, nil, err)
}
return walkFiles(fs, root, info, file, walkFn)
}
// walkFiles recursively descends path, calling walkFn.
// It closes the input file after it's done with it, so the caller shouldn't.
func walkFiles(fs http.FileSystem, path string, info os.FileInfo, file http.File, walkFn WalkFilesFunc) error {
err := walkFn(path, info, file, nil)
file.Close()
if err != nil {
if info.IsDir() && err == filepath.SkipDir {
return nil
}
return err
}
if !info.IsDir() {
return nil
}
names, err := readDirNames(fs, path)
if err != nil {
return walkFn(path, info, nil, err)
}
for _, name := range names {
filename := pathpkg.Join(path, name)
file, fileInfo, err := openStat(fs, filename)
if err != nil {
if err := walkFn(filename, nil, nil, err); err != nil && err != filepath.SkipDir {
return err
}
} else {
err = walkFiles(fs, filename, fileInfo, file, walkFn)
// file is closed by walkFiles, so we don't need to close it here.
if err != nil {
if !fileInfo.IsDir() || err != filepath.SkipDir {
return err
}
}
}
}
return nil
}
// openStat performs Open and Stat and returns results, or first error encountered.
// The caller is responsible for closing the returned file when done.
func openStat(fs http.FileSystem, name string) (http.File, os.FileInfo, error) {
f, err := fs.Open(name)
if err != nil {
return nil, nil, err
}
fi, err := f.Stat()
if err != nil {
f.Close()
return nil, nil, err
}
return f, fi, nil
}

View File

@@ -1,93 +0,0 @@
package vfsutil_test
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"github.com/shurcooL/httpfs/vfsutil"
"golang.org/x/tools/godoc/vfs/httpfs"
"golang.org/x/tools/godoc/vfs/mapfs"
)
func ExampleWalk() {
var fs http.FileSystem = httpfs.New(mapfs.New(map[string]string{
"zzz-last-file.txt": "It should be visited last.",
"a-file.txt": "It has stuff.",
"another-file.txt": "Also stuff.",
"folderA/entry-A.txt": "Alpha.",
"folderA/entry-B.txt": "Beta.",
}))
walkFn := func(path string, fi os.FileInfo, err error) error {
if err != nil {
log.Printf("can't stat file %s: %v\n", path, err)
return nil
}
fmt.Println(path)
return nil
}
err := vfsutil.Walk(fs, "/", walkFn)
if err != nil {
panic(err)
}
// Output:
// /
// /a-file.txt
// /another-file.txt
// /folderA
// /folderA/entry-A.txt
// /folderA/entry-B.txt
// /zzz-last-file.txt
}
func ExampleWalkFiles() {
var fs http.FileSystem = httpfs.New(mapfs.New(map[string]string{
"zzz-last-file.txt": "It should be visited last.",
"a-file.txt": "It has stuff.",
"another-file.txt": "Also stuff.",
"folderA/entry-A.txt": "Alpha.",
"folderA/entry-B.txt": "Beta.",
}))
walkFn := func(path string, fi os.FileInfo, r io.ReadSeeker, err error) error {
if err != nil {
log.Printf("can't stat file %s: %v\n", path, err)
return nil
}
fmt.Println(path)
if !fi.IsDir() {
b, err := ioutil.ReadAll(r)
if err != nil {
log.Printf("can't read file %s: %v\n", path, err)
return nil
}
fmt.Printf("%q\n", b)
}
return nil
}
err := vfsutil.WalkFiles(fs, "/", walkFn)
if err != nil {
panic(err)
}
// Output:
// /
// /a-file.txt
// "It has stuff."
// /another-file.txt
// "Also stuff."
// /folderA
// /folderA/entry-A.txt
// "Alpha."
// /folderA/entry-B.txt
// "Beta."
// /zzz-last-file.txt
// "It should be visited last."
}

View File

@@ -8,7 +8,7 @@ This help page aims to cover two aspects of micro's syntax highlighting engine:
## Colorschemes
To change your colorscheme, press CtrlE in micro to bring up the command
To change your colorscheme, press Ctrl-e in micro to bring up the command
prompt, and type:
```

View File

@@ -1,6 +1,6 @@
# Command bar
The command bar is opened by pressing CtrlE. It is a single-line buffer,
The command bar is opened by pressing Ctrl-e. It is a single-line buffer,
meaning that all keybindings from a normal buffer are supported (as well
as mouse and selection).
@@ -13,7 +13,7 @@ does not look up environment variables.
# Commands
Micro provides the following commands that can be executed at the command-bar
by pressing `CtrlE` and entering the command. Arguments are placed in single
by pressing `Ctrl-e` and entering the command. Arguments are placed in single
quotes here but these are not necessary when entering the command in micro.
* `bind 'key' 'action'`: creates a keybinding from key to action. See the
@@ -109,7 +109,7 @@ quotes here but these are not necessary when entering the command in micro.
is most useful for debugging keybindings.
* `showkey`: Show the action(s) bound to a given key. For example
running `> showkey CtrlC` will display `Copy`.
running `> showkey Ctrl-c` will display `Copy`.
* `term exec?`: Open a terminal emulator running the given executable. If no
executable is given, this will open the default shell in the terminal

View File

@@ -80,7 +80,7 @@ can change it!
| Ctrl-z | Undo |
| Ctrl-y | Redo |
| Alt-UpArrow | Move current line or selected lines up |
| Alt-DownArrow | Move current line of selected lines down |
| Alt-DownArrow | Move current line or selected lines down |
| Alt-Backspace or Alt-Ctrl-h | Delete word left |
| Ctrl-a | Select all |

View File

@@ -4,9 +4,9 @@ Micro is a terminal-based text editor that aims to be easy to use and
intuitive, while also taking advantage of the full capabilities of modern
terminals.
To open the command bar, press CtrlE. This enables a `>` prompt for typing
To open the command bar, press Ctrl-e. This enables a `>` prompt for typing
commands. From now on when the documentation says to run a command such as `>
help`, this means press CtrlE and type `help` (and press enter to execute the
help`, this means press Ctrl-e and type `help` (and press enter to execute the
command).
For a list of the default keybindings run `> help defaultkeys`.
@@ -14,7 +14,7 @@ For more information on keybindings see `> help keybindings`.
## Quick-start
Press Ctrl-q to quit, and Ctrl-s to save. Press CtrlE to start typing commands
Press Ctrl-q to quit, and Ctrl-s to save. Press Ctrl-e to start typing commands
and you can see which commands are available by pressing tab, or by viewing the
help topic `> help commands`.
@@ -34,7 +34,7 @@ Press Ctrl-w to move between splits, and type `> vsplit filename` or
Micro has a built-in help system which can be accessed with the `help` command.
To use it, press CtrlE to access command mode and type in `help` followed by a
To use it, press Ctrl-e to access command mode and type in `help` followed by a
topic. Typing `help` followed by nothing will open this page.
Here are the possible help topics that you can read:

View File

@@ -30,11 +30,17 @@ following in the `bindings.json` file.
```json
{
"CtrlY": "Undo",
"CtrlZ": "Redo"
"Ctrl-y": "Undo",
"Ctrl-z": "Redo"
}
```
**Note:** The syntax `<Modifier><key>` is equivalent to `<Modifier>-<key>`. In
addition, Ctrl-Shift bindings are not supported by terminals, and are the same
as simply Ctrl bindings. This means that `CtrlG`, `Ctrl-G`, and `Ctrl-g` all
mean the same thing. However, for Alt this is not the case: `AltG` and `Alt-G`
mean `Alt-Shift-g`, while `Alt-g` does not require the Shift modifier.
In addition to editing your `~/.config/micro/bindings.json`, you can run
`>bind <keycombo> <action>` For a list of bindable actions, see below.
@@ -85,15 +91,15 @@ your working directory in the infobar.
You can also bind an "editable" command with `command-edit:`. This means that
micro won't immediately execute the command when you press the binding, but
instead just place the string in the infobar in command mode. For example,
you could rebind `CtrlG` to `> help`:
you could rebind `Ctrl-g` to `> help`:
```json
{
"CtrlG": "command-edit:help "
"Ctrl-g": "command-edit:help "
}
```
Now when you press `CtrlG`, `help` will appear in the command bar and your
Now when you press `Ctrl-g`, `help` will appear in the command bar and your
cursor will be placed after it (note the space in the json that controls the
cursor placement).
@@ -357,32 +363,32 @@ F62
F63
F64
CtrlSpace
CtrlA
CtrlB
CtrlC
CtrlD
CtrlE
CtrlF
CtrlG
CtrlH
CtrlI
CtrlJ
CtrlK
CtrlL
CtrlM
CtrlN
CtrlO
CtrlP
CtrlQ
CtrlR
CtrlS
CtrlT
CtrlU
CtrlV
CtrlW
CtrlX
CtrlY
CtrlZ
Ctrl-a
Ctrl-b
Ctrl-c
Ctrl-d
Ctrl-e
Ctrl-f
Ctrl-g
Ctrl-h
Ctrl-i
Ctrl-j
Ctrl-k
Ctrl-l
Ctrl-m
Ctrl-n
Ctrl-o
Ctrl-p
Ctrl-q
Ctrl-r
Ctrl-s
Ctrl-t
Ctrl-u
Ctrl-v
Ctrl-w
Ctrl-x
Ctrl-y
Ctrl-z
CtrlLeftSq
CtrlBackslash
CtrlRightSq
@@ -450,28 +456,28 @@ conventions for text editing defaults.
"Alt-{": "ParagraphPrevious",
"Alt-}": "ParagraphNext",
"Enter": "InsertNewline",
"CtrlH": "Backspace",
"Ctrl-h": "Backspace",
"Backspace": "Backspace",
"Alt-CtrlH": "DeleteWordLeft",
"Alt-Backspace": "DeleteWordLeft",
"Tab": "Autocomplete|IndentSelection|InsertTab",
"Backtab": "OutdentSelection|OutdentLine",
"CtrlO": "OpenFile",
"CtrlS": "Save",
"CtrlF": "Find",
"CtrlN": "FindNext",
"CtrlP": "FindPrevious",
"CtrlZ": "Undo",
"CtrlY": "Redo",
"CtrlC": "CopyLine|Copy",
"CtrlX": "Cut",
"CtrlK": "CutLine",
"CtrlD": "DuplicateLine",
"CtrlV": "Paste",
"CtrlA": "SelectAll",
"CtrlT": "AddTab",
"Alt,": "PreviousTab",
"Alt.": "NextTab",
"Ctrl-o": "OpenFile",
"Ctrl-s": "Save",
"Ctrl-f": "Find",
"Ctrl-n": "FindNext",
"Ctrl-p": "FindPrevious",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-k": "CutLine",
"Ctrl-d": "DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
"Ctrl-t": "AddTab",
"Alt-,": "PreviousTab",
"Alt-.": "NextTab",
"Home": "StartOfText",
"End": "EndOfLine",
"CtrlHome": "CursorStart",
@@ -480,17 +486,17 @@ conventions for text editing defaults.
"PageDown": "CursorPageDown",
"CtrlPageUp": "PreviousTab",
"CtrlPageDown": "NextTab",
"CtrlG": "ToggleHelp",
"Ctrl-g": "ToggleHelp",
"Alt-g": "ToggleKeyMenu",
"CtrlR": "ToggleRuler",
"CtrlL": "command-edit:goto ",
"Ctrl-r": "ToggleRuler",
"Ctrl-l": "command-edit:goto ",
"Delete": "Delete",
"CtrlB": "ShellMode",
"CtrlQ": "Quit",
"CtrlE": "CommandMode",
"CtrlW": "NextSplit",
"CtrlU": "ToggleMacro",
"CtrlJ": "PlayMacro",
"Ctrl-b": "ShellMode",
"Ctrl-q": "Quit",
"Ctrl-e": "CommandMode",
"Ctrl-w": "NextSplit",
"Ctrl-u": "ToggleMacro",
"Ctrl-j": "PlayMacro",
"Insert": "ToggleOverwriteMode",
// Emacs-style keybindings
@@ -526,7 +532,7 @@ conventions for text editing defaults.
## Final notes
Note: On some old terminal emulators and on Windows machines, `CtrlH` should be
Note: On some old terminal emulators and on Windows machines, `Ctrl-h` should be
used for backspace.
Additionally, alt keys can be bound by using `Alt-key`. For example `Alt-a` or

View File

@@ -16,8 +16,8 @@ the settings and their values. To change an option, you can either change the
value in the `settings.json` file, or you can type it in directly while using
micro.
Press CtrlE to go to command mode, and type `set option value` (in the
future, I will use `> set option value` to indicate pressing CtrlE). The change
Press Ctrl-e to go to command mode, and type `set option value` (in the
future, I will use `> set option value` to indicate pressing Ctrl-e). The change
will take effect immediately and will also be saved to the `settings.json` file
so that the setting will stick even after you close micro.
@@ -48,12 +48,12 @@ If you would like to know more about all the available options, see the
Keybindings work in much the same way as options. You configure them using the
`~/.config/micro/bindings.json` file.
For example if you would like to bind `CtrlR` to redo you could put the
For example if you would like to bind `Ctrl-r` to redo you could put the
following in `bindings.json`:
```json
{
"CtrlR": "redo"
"Ctrl-r": "redo"
}
```
@@ -74,7 +74,7 @@ micro starts and is essentially a one-file plugin. The plugin name is
`initlua`.
This example will show you how to use the `init.lua` file by creating a binding
to `CtrlR` which will execute the bash command `go run` on the current file,
to `Ctrl-r` which will execute the bash command `go run` on the current file,
given that the current file is a Go file.
You can do that by putting the following in `init.lua`:
@@ -84,9 +84,9 @@ local config = import("micro/config")
local shell = import("micro/shell")
function init()
-- true means overwrite any existing binding to CtrlR
-- true means overwrite any existing binding to Ctrl-r
-- this will modify the bindings.json file
config.TryBindKey("CtrlR", "lua:initlua.gorun", true)
config.TryBindKey("Ctrl-r", "lua:initlua.gorun", true)
end
function gorun(bp)
@@ -104,7 +104,7 @@ the `bindings.json` file:
```json
{
"CtrlR": "lua:initlua.gorun"
"Ctrl-r": "lua:initlua.gorun"
}
```

View File

@@ -143,5 +143,6 @@ end
function init()
config.MakeCommand("comment", comment, config.NoComplete)
config.TryBindKey("Alt-/", "lua:comment.comment", false)
config.TryBindKey("CtrlUnderscore", "lua:comment.comment", false)
config.AddRuntimeFile("comment", config.RTHelp, "help/comment.md")
end

View File

@@ -1,8 +1,10 @@
# Comment Plugin
The comment plugin provides auto commenting/uncommenting.
The default binding to comment/uncomment a line is `Alt-/`,
but you can easily modify that in your `bindings.json` file:
The default binding to comment/uncomment a line is `Alt-/`
and `CtrlUnderscore`, which is equivalent in most terminals
to `Ctrl-/`. You can easily modify that in your `bindings.json`
file:
```json
{

View File

@@ -1,22 +1,14 @@
// +build ignore
// This script generates the embedded runtime filesystem, and also creates
// syntax header metadata which makes loading syntax files at runtime faster
// Invoke as go run runtime_generate.go syntaxDir runtimeDir
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
"time"
yaml "gopkg.in/yaml.v2"
"github.com/shurcooL/vfsgen"
)
type HeaderYaml struct {
@@ -33,6 +25,19 @@ type Header struct {
HeaderRgx string
}
func main() {
if len(os.Args) > 1 {
os.Chdir(os.Args[1])
}
files, _ := ioutil.ReadDir(".")
for _, f := range files {
fname := f.Name()
if strings.HasSuffix(fname, ".yaml") {
convert(fname[:len(fname)-5])
}
}
}
func convert(name string) {
filename := name + ".yaml"
var hdr HeaderYaml
@@ -56,57 +61,14 @@ func encode(name string, c HeaderYaml) {
}
func decode(name string) Header {
start := time.Now()
data, _ := ioutil.ReadFile(name + ".hdr")
strs := bytes.Split(data, []byte{'\n'})
var hdr Header
hdr.FileType = string(strs[0])
hdr.FNameRgx = string(strs[1])
hdr.HeaderRgx = string(strs[2])
fmt.Printf("took %v\n", time.Since(start))
return hdr
}
func main() {
orig, err := os.Getwd()
if err != nil {
log.Fatalln("Couldn't get cwd")
return
}
if len(os.Args) < 2 {
log.Fatalln("Not enough arguments")
}
syntaxDir := os.Args[1]
assetDir := os.Args[2]
os.Chdir(syntaxDir)
files, _ := ioutil.ReadDir(".")
// first remove all existing header files (clean the directory)
for _, f := range files {
fname := f.Name()
if strings.HasSuffix(fname, ".hdr") {
os.Remove(fname)
}
}
// now create a header file for each yaml
for _, f := range files {
fname := f.Name()
if strings.HasSuffix(fname, ".yaml") {
convert(fname[:len(fname)-5])
}
}
// create the assets_vfsdata.go file for embedding in the binary
os.Chdir(orig)
var assets http.FileSystem = http.Dir(assetDir)
err = vfsgen.Generate(assets, vfsgen.Options{
PackageName: "config",
VariableName: "Assets",
})
if err != nil {
log.Fatalln(err)
}
}

1
tools/go-bindata Submodule

Submodule tools/go-bindata added at 9453701aa0

View File

@@ -1,161 +1,43 @@
# This script creates the nightly release on Github for micro
# You must have the correct Github access token to run this script
# Must be run from inside the micro git repository
commitID=$(git rev-parse HEAD)
info=$(github-release info -u zyedidia -r micro -t nightly)
commitID=$(git rev-parse --short HEAD)
# info=$(github-release info -u zyedidia -r micro -t nightly)
if [[ $info = *$commitID* ]]; then
echo "No new commits since last nightly"
exit 1
fi
# if [[ $info = *$commitID* ]]; then
# echo "No new commits since last nightly"
# exit 1
# fi
echo "Deleting old release"
github-release delete \
--user zyedidia \
--repo micro \
--tag nightly
go run remove-nightly-assets.go
echo "Moving tag"
git tag --force nightly $commitID
git push --force --tags
echo "Creating new release"
github-release release \
--user zyedidia \
--repo micro \
--tag nightly \
--name "Nightly build" \
--description "Autogenerated nightly build of micro. If you don't see anything here that probably means it's building right now!" \
--pre-release
# echo "Moving tag"
# hub push origin :refs/tags/nightly
# git tag -f nightly $commitID
# hub push --tags
echo "Cross compiling binaries"
./cross-compile.sh $1
mv ../binaries .
echo "Uploading OSX binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-osx.tar.gz" \
--file binaries/micro-$1-osx.tar.gz
MESSAGE=$'Nightly build\n\nAutogenerated nightly build of micro'
echo "Uploading Linux 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-linux64.tar.gz" \
--file binaries/micro-$1-linux64.tar.gz
echo "Uploading Linux 64 static binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-linux64-static.tar.gz" \
--file binaries/micro-$1-linux64-static.tar.gz
echo "Uploading Linux 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-linux32.tar.gz" \
--file binaries/micro-$1-linux32.tar.gz
echo "Uploading Linux Arm 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-linux-arm.tar.gz" \
--file binaries/micro-$1-linux-arm.tar.gz
echo "Uploading Linux Arm 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-linux-arm64.tar.gz" \
--file binaries/micro-$1-linux-arm64.tar.gz
echo "Uploading FreeBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-freebsd64.tar.gz" \
--file binaries/micro-$1-freebsd64.tar.gz
echo "Uploading FreeBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-freebsd32.tar.gz" \
--file binaries/micro-$1-freebsd32.tar.gz
echo "Uploading OpenBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-openbsd64.tar.gz" \
--file binaries/micro-$1-openbsd64.tar.gz
echo "Uploading OpenBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-openbsd32.tar.gz" \
--file binaries/micro-$1-openbsd32.tar.gz
echo "Uploading NetBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-netbsd64.tar.gz" \
--file binaries/micro-$1-netbsd64.tar.gz
echo "Uploading NetBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-netbsd32.tar.gz" \
--file binaries/micro-$1-netbsd32.tar.gz
echo "Uploading Windows 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-win64.zip" \
--file binaries/micro-$1-win64.zip
echo "Uploading Windows 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag nightly \
--name "micro-$1-win32.zip" \
--file binaries/micro-$1-win32.zip
# echo "Uploading vendored tarball"
# github-release upload \
# --user zyedidia \
# --repo micro \
# --tag nightly \
# --name "micro-$1-src.tar.gz" \
# --file binaries/micro-$1-src.tar.gz
#
# echo "Uploading vendored zip"
# github-release upload \
# --user zyedidia \
# --repo micro \
# --tag nightly \
# --name "micro-$1-src.zip" \
# --file binaries/micro-$1-src.zip
echo "Creating new release"
hub release edit nightly \
--prerelease \
--draft=false \
--message "$MESSAGE. Assets uploaded on $(date) for commit $commitID." \
--attach "binaries/micro-$1-osx.tar.gz" \
--attach "binaries/micro-$1-linux64.tar.gz" \
--attach "binaries/micro-$1-linux64-static.tar.gz" \
--attach "binaries/micro-$1-linux32.tar.gz" \
--attach "binaries/micro-$1-linux-arm.tar.gz" \
--attach "binaries/micro-$1-linux-arm64.tar.gz" \
--attach "binaries/micro-$1-freebsd64.tar.gz" \
--attach "binaries/micro-$1-freebsd32.tar.gz" \
--attach "binaries/micro-$1-openbsd64.tar.gz" \
--attach "binaries/micro-$1-openbsd32.tar.gz" \
--attach "binaries/micro-$1-netbsd64.tar.gz" \
--attach "binaries/micro-$1-netbsd32.tar.gz" \
--attach "binaries/micro-$1-win64.zip" \
--attach "binaries/micro-$1-win32.zip"

View File

@@ -8,145 +8,29 @@ tag="v$1"
echo "Creating tag"
git tag $tag $commitID
git push --tags
echo "Creating new release"
github-release release \
--user zyedidia \
--repo micro \
--tag $tag \
--name "$1" \
--description "$2" \
--pre-release
hub push --tags
echo "Cross compiling binaries"
./cross-compile.sh $1
mv ../binaries .
echo "Uploading OSX binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-osx.tar.gz" \
--file binaries/micro-$1-osx.tar.gz
NL=$'\n'
echo "Uploading Linux 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux64.tar.gz" \
--file binaries/micro-$1-linux64.tar.gz
echo "Uploading Linux 64 static binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux64-static.tar.gz" \
--file binaries/micro-$1-linux64-static.tar.gz
echo "Uploading Linux 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux32.tar.gz" \
--file binaries/micro-$1-linux32.tar.gz
echo "Uploading Linux Arm 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux-arm.tar.gz" \
--file binaries/micro-$1-linux-arm.tar.gz
echo "Uploading Linux Arm 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux-arm64.tar.gz" \
--file binaries/micro-$1-linux-arm64.tar.gz
echo "Uploading FreeBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-freebsd64.tar.gz" \
--file binaries/micro-$1-freebsd64.tar.gz
echo "Uploading FreeBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-freebsd32.tar.gz" \
--file binaries/micro-$1-freebsd32.tar.gz
echo "Uploading OpenBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-openbsd64.tar.gz" \
--file binaries/micro-$1-openbsd64.tar.gz
echo "Uploading OpenBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-openbsd32.tar.gz" \
--file binaries/micro-$1-openbsd32.tar.gz
echo "Uploading NetBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-netbsd64.tar.gz" \
--file binaries/micro-$1-netbsd64.tar.gz
echo "Uploading NetBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-netbsd32.tar.gz" \
--file binaries/micro-$1-netbsd32.tar.gz
echo "Uploading Windows 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-win64.zip" \
--file binaries/micro-$1-win64.zip
echo "Uploading Windows 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-win32.zip" \
--file binaries/micro-$1-win32.zip
# echo "Uploading vendored tarball"
# github-release upload \
# --user zyedidia \
# --repo micro \
# --tag $tag \
# --name "micro-$1-src.tar.gz" \
# --file binaries/micro-$1-src.tar.gz
#
# echo "Uploading vendored zip"
# github-release upload \
# --user zyedidia \
# --repo micro \
# --tag $tag \
# --name "micro-$1-src.zip" \
# --file binaries/micro-$1-src.zip
echo "Creating new release"
hub release create $tag \
--prerelease \
--message "$1${NL}${NL}$2" \
--attach "binaries/micro-$1-osx.tar.gz" \
--attach "binaries/micro-$1-linux64.tar.gz" \
--attach "binaries/micro-$1-linux64-static.tar.gz" \
--attach "binaries/micro-$1-linux32.tar.gz" \
--attach "binaries/micro-$1-linux-arm.tar.gz" \
--attach "binaries/micro-$1-linux-arm64.tar.gz" \
--attach "binaries/micro-$1-freebsd64.tar.gz" \
--attach "binaries/micro-$1-freebsd32.tar.gz" \
--attach "binaries/micro-$1-openbsd64.tar.gz" \
--attach "binaries/micro-$1-openbsd32.tar.gz" \
--attach "binaries/micro-$1-netbsd64.tar.gz" \
--attach "binaries/micro-$1-netbsd32.tar.gz" \
--attach "binaries/micro-$1-win64.zip" \
--attach "binaries/micro-$1-win32.zip"

View File

@@ -8,144 +8,28 @@ tag="v$1"
echo "Creating tag"
git tag $tag $commitID
git push --tags
hub push --tags
echo "Creating new release"
github-release release \
--user zyedidia \
--repo micro \
--tag $tag \
--name "$1" \
--description "$2" \
NL=$'\n'
echo "Cross compiling binaries"
./cross-compile.sh $1
mv ../binaries .
echo "Uploading OSX binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-osx.tar.gz" \
--file binaries/micro-$1-osx.tar.gz
echo "Uploading Linux 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux64.tar.gz" \
--file binaries/micro-$1-linux64.tar.gz
echo "Uploading Linux 64 static binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux64-static.tar.gz" \
--file binaries/micro-$1-linux64-static.tar.gz
echo "Uploading Linux 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux32.tar.gz" \
--file binaries/micro-$1-linux32.tar.gz
echo "Uploading Linux Arm 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux-arm.tar.gz" \
--file binaries/micro-$1-linux-arm.tar.gz
echo "Uploading Linux Arm 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-linux-arm64.tar.gz" \
--file binaries/micro-$1-linux-arm64.tar.gz
echo "Uploading FreeBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-freebsd64.tar.gz" \
--file binaries/micro-$1-freebsd64.tar.gz
echo "Uploading FreeBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-freebsd32.tar.gz" \
--file binaries/micro-$1-freebsd32.tar.gz
echo "Uploading OpenBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-openbsd64.tar.gz" \
--file binaries/micro-$1-openbsd64.tar.gz
echo "Uploading OpenBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-openbsd32.tar.gz" \
--file binaries/micro-$1-openbsd32.tar.gz
echo "Uploading NetBSD 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-netbsd64.tar.gz" \
--file binaries/micro-$1-netbsd64.tar.gz
echo "Uploading NetBSD 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-netbsd32.tar.gz" \
--file binaries/micro-$1-netbsd32.tar.gz
echo "Uploading Windows 64 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-win64.zip" \
--file binaries/micro-$1-win64.zip
echo "Uploading Windows 32 binary"
github-release upload \
--user zyedidia \
--repo micro \
--tag $tag \
--name "micro-$1-win32.zip" \
--file binaries/micro-$1-win32.zip
# echo "Uploading vendored tarball"
# github-release upload \
# --user zyedidia \
# --repo micro \
# --tag $tag \
# --name "micro-$1-src.tar.gz" \
# --file binaries/micro-$1-src.tar.gz
#
# echo "Uploading vendored zip"
# github-release upload \
# --user zyedidia \
# --repo micro \
# --tag $tag \
# --name "micro-$1-src.zip" \
# --file binaries/micro-$1-src.zip
echo "Creating new release"
hub release create $tag \
--message "$1${NL}${NL}$2" \
--attach "binaries/micro-$1-osx.tar.gz" \
--attach "binaries/micro-$1-linux64.tar.gz" \
--attach "binaries/micro-$1-linux64-static.tar.gz" \
--attach "binaries/micro-$1-linux32.tar.gz" \
--attach "binaries/micro-$1-linux-arm.tar.gz" \
--attach "binaries/micro-$1-linux-arm64.tar.gz" \
--attach "binaries/micro-$1-freebsd64.tar.gz" \
--attach "binaries/micro-$1-freebsd32.tar.gz" \
--attach "binaries/micro-$1-openbsd64.tar.gz" \
--attach "binaries/micro-$1-openbsd32.tar.gz" \
--attach "binaries/micro-$1-netbsd64.tar.gz" \
--attach "binaries/micro-$1-netbsd32.tar.gz" \
--attach "binaries/micro-$1-win64.zip" \
--attach "binaries/micro-$1-win32.zip"

View File

@@ -0,0 +1,39 @@
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os/exec"
"strings"
"github.com/zyedidia/json5"
)
func main() {
resp, err := http.Get("https://api.github.com/repos/zyedidia/micro/releases")
if err != nil {
fmt.Println(err.Error())
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var data interface{}
err = json5.Unmarshal(body, &data)
for _, val := range data.([]interface{}) {
m := val.(map[string]interface{})
releaseName := m["name"].(string)
assets := m["assets"].([]interface{})
for _, asset := range assets {
assetInfo := asset.(map[string]interface{})
url := assetInfo["url"].(string)
if strings.Contains(strings.ToLower(releaseName), "nightly") {
cmd := exec.Command("hub", "api", "-X", "DELETE", url)
cmd.Run()
}
}
}
}