Compare commits

..

78 Commits

Author SHA1 Message Date
Zachary Yedidia
5dc8fe40ca Add option to disable use of a the primary clipboard
Closes #544
2017-02-07 19:21:25 -05:00
Zachary Yedidia
28af256be0 Fix stringwidth build 2017-02-03 07:32:48 -05:00
Zachary Yedidia
c3a165e61d Merge pull request #539 from samdmarshall/nim
Adding syntax and linter support for nim-lang
2017-02-02 23:00:12 -05:00
Zachary Yedidia
33e5dd4aed Update runtime 2017-01-27 10:32:58 -05:00
Samantha Marshall
9122f152d1 fixing thestart/end syntax 2017-01-27 08:40:41 -05:00
Samantha Marshall
2202b32f31 finishing up syntax file 2017-01-26 15:50:54 -05:00
Samantha Marshall
15ab0b2fed adding nim linter and syntax 2017-01-26 14:19:07 -05:00
Zachary Yedidia
a8b0f6d679 Merge pull request #531 from bazzilic/patch-1
Update README.md to mention chocolatey package
2017-01-25 14:32:14 -05:00
Zachary Yedidia
40411ea627 Merge pull request #533 from onodera-punpun/toml
Add toml syntax file
2017-01-25 14:32:04 -05:00
Zachary Yedidia
8a6a3127c6 Merge pull request #534 from onodera-punpun/go2
update go syntax file
2017-01-25 14:31:53 -05:00
Zachary Yedidia
f951c6f489 Merge pull request #535 from yursan9/patch-1
Correct the splitBottom option
2017-01-25 14:31:41 -05:00
Yurizal Susanto
82a3b8bb39 Correct the splitBottom option 2017-01-24 10:40:36 +07:00
onodera-punpun
c29ccfe011 update go syntax file 2017-01-23 20:06:39 +01:00
onodera-punpun
d48efbf442 Add toml syntax file 2017-01-23 20:01:26 +01:00
bazzilic
69ef6def38 Update README.md to mention chocolatey package 2017-01-23 14:41:52 +08:00
DanielPower
f7560c3311 Add gruvbox truecolor colorscheme (#530)
* Add gruvbox truecolor colorscheme

* Fixed typo in gruvbox-tv, added operator type in colorschemes

* Added operator type to all default themes

* Changed operator to symbol

* changed operator to symbol due to name conflict

* Removed unused 'operator' field. Fixed gutter-error color

* Restored the statement group and removed operator
2017-01-20 14:32:34 -05:00
Samantha Marshall
ea57d8b883 Adding additional Python and Objective-C linting (#524)
* adding mypy and pylint to the linter plugin

* adding objective-c linting

* updating runtime file
2017-01-17 16:34:11 -05:00
Nicolai Søborg
41fb57e449 Fix: incorrect clipboard w/ CutLine, DeleteLine and Search (#508)
* Fix: incorrect clipboard w/ CutLine, DeleteLine and Search

* Refactor: Add Cursor.CopySelection(clipboard)
2017-01-09 18:28:45 -05:00
Zachary Yedidia
ae566920b6 Merge pull request #518 from samdmarshall/key-unbinding
Key unbinding
2017-01-04 13:56:34 -05:00
Zachary Yedidia
036ed7b9ed Add SaveAs action
Fixes #509
2017-01-04 13:51:17 -05:00
Zachary Yedidia
5775b4c05d Fix gutter coloring for soft wrap
Fixes #511
2017-01-04 13:29:57 -05:00
Samantha Marshall
29502e7f41 simplify the code around unbinding keys 2017-01-02 11:28:47 -05:00
Samantha Marshall
362d8eabae Adding functionality to unbind keys
* adds new special-case keybinding to remove an existing default key binding.
* hides the show/close help text in the status line when no key is assigned to "ToggleHelp"
* updating documentation
2017-01-02 10:56:55 -05:00
Zachary Yedidia
a3c58e52fc Merge pull request #513 from samdmarshall/master
Adding embedded Info.plist to OS X builds
2016-12-29 18:55:28 -05:00
Zachary Yedidia
1edd161684 Merge pull request #510 from legionus/email-syntax
Add mail syntax highlighting
2016-12-28 17:30:47 -05:00
Samantha Marshall
7f95891a9a Adding embedded Info.plist to OS X builds. 2016-12-28 13:17:54 -05:00
Alexey Gladkov
80c6c8ef9f Add mail syntax highlighting 2016-12-28 18:18:19 +01:00
Zachary Yedidia
143339dd67 Merge 2016-12-26 10:34:41 -05:00
Zachary Yedidia
7611c13d12 Better fix for mouse clicking 2016-12-26 10:33:41 -05:00
Zachary Yedidia
d49e366413 Merge pull request #507 from NicolaiSoeborg/master
Fix travis build (new imports for gopher-luar)
2016-12-25 10:56:53 -05:00
Nicolai
ac5fbd9515 Fix travis build (new imports for gopher-luar)
See
24588ee686
2016-12-25 15:42:18 +01:00
Zachary Yedidia
aef75f9b83 Fix bug with mouse clicks
Fixes #504
2016-12-24 15:34:01 -05:00
Zachary Yedidia
faec861081 Update php rules 2016-12-23 18:25:47 -05:00
Nicolai
5a9a7a3835 Merge remote-tracking branch 'refs/remotes/zyedidia/master' 2016-12-24 00:24:12 +01:00
Zachary Yedidia
2649b673f7 Merge 2016-12-22 18:34:15 -05:00
Zachary Yedidia
7958dc0592 Update php syntax rules 2016-12-22 18:34:10 -05:00
Zachary Yedidia
379a49f944 Merge pull request #488 from McSwaggens/removewhitespaces-setting
Added removewhitespaces setting
2016-12-22 17:49:49 -05:00
Daniel Jones
a311e07106 Changed removewhitespaces setting to keepautoindent 2016-12-23 09:44:57 +11:00
Zachary Yedidia
496fab031c Merge 2016-12-22 16:38:24 -05:00
Zachary Yedidia
1a95f34b0e Fix prompts not displaying 2016-12-22 16:38:20 -05:00
Zachary Yedidia
d560de4b40 Merge pull request #499 from 10sr/addrmtrailingws
[Proposal] Add feature to trim trailing whitespaces on save
2016-12-22 15:45:55 -05:00
Zachary Yedidia
0d9fc601ac Merge pull request #489 from november-eleven/refactor/plugin-name
Enable human-friendly plugin name
2016-12-22 15:44:09 -05:00
Zachary Yedidia
325c9111eb Merge pull request #502 from samdmarshall/master
preventing messages from over-writing the current prompt text
2016-12-18 18:38:03 -05:00
Samantha Marshall
968d5be74e fixing test, was using incorrect assignment syntax 2016-12-18 15:29:22 -05:00
Samantha Marshall
71ee042218 preventing messages from over-writing the current prompt message 2016-12-18 15:14:18 -05:00
Zachary Yedidia
d826db89d6 Merge pull request #501 from samdmarshall/master
updating micro syntax to better work with micro syntax files
2016-12-17 20:56:01 -05:00
Samantha Marshall
7db856d39d updating micro syntax to better work with micro syntax files 2016-12-17 20:47:25 -05:00
Zachary Yedidia
f90054cf25 Merge pull request #500 from NicolaiSoeborg/patch-1
Fix: mouse clicking with softwrap
2016-12-17 19:50:13 -05:00
Nicolai Søborg
37ae99ccd9 Fix: mouse clicking with softwrap
When clicking on a long line with softwrap turned on, the cursor will show up in the wrong location (`screenY` will be wrong in `GetSoftWrapLocation`). This seems to fix it.
2016-12-18 00:27:06 +01:00
10sr
e71b49481b Update help for rmtrailingws 2016-12-17 11:33:48 +09:00
10sr
701d0dfe3d Add rmtrailingws feature 2016-12-17 11:33:48 +09:00
Zachary Yedidia
3f02e12539 Merge pull request #497 from 10sr/fixeolnewline
Fix bug that eofnewline does not work on save
2016-12-16 14:41:06 -05:00
10sr
5b689a5592 Fix bug that eofnewline does not work on save 2016-12-15 16:29:50 +09:00
Zachary Yedidia
2bc70890f0 Merge pull request #495 from ColinRioux/master
Minor fix to documentation
2016-12-14 15:13:18 -05:00
Colin Rioux
4e5aa4ecc8 Minor fix to documentation 2016-12-14 15:11:57 -05:00
Zachary Yedidia
5f50d79efa Update docs
Fixes #486
2016-12-14 10:30:03 -05:00
Zachary Yedidia
000197fd28 Merge pull request #493 from Theodus/tabs
Move to new tab when created
2016-12-13 12:30:42 -05:00
theodus
4cb26d2e8e move to new tab 2016-12-13 12:12:20 -05:00
Zachary Yedidia
1d41634272 Add missing word boundary to python regex
Fixes #490
2016-12-13 09:27:54 -05:00
Zachary Yedidia
32e8284505 Expand '~' in SaveAs
Fixes #491
2016-12-13 08:58:08 -05:00
Thomas LE ROUX
651cb89948 refactor(plugin): Enable human-friendly plugin name 2016-12-12 16:37:48 +01:00
Zachary Yedidia
63f18f033c Update runtime 2016-12-11 16:43:07 -05:00
Daniel Jones
0558de12c6 Added removewhitespaces setting 2016-12-11 23:01:10 +11:00
Zachary Yedidia
95293457fb Merge 2016-12-10 20:36:08 -05:00
Zachary Yedidia
d71ad04d98 Display colorscheme error message using TermMessage 2016-12-10 20:36:03 -05:00
Zachary Yedidia
7134cc8e1c Merge pull request #487 from NicolaiSoeborg/patch-1
Update plugin documentation
2016-12-10 20:16:28 -05:00
Nicolai Søborg
3de440338d Update plugin documentation 2016-12-11 01:24:49 +01:00
Zachary Yedidia
73d14f5d37 Merge pull request #485 from sirikid/syntax-fix
Initial OCaml support (integer and real literals, comments)
2016-12-09 10:41:38 -05:00
Zachary Yedidia
291b1d1efc Use shell to parse command when using JobStart
Also changed all occurrences of JobStart to JobSpawn in the linter
plugin.
2016-12-09 10:34:39 -05:00
Ivan Sokolov
57960bdc81 Initial OCaml support (integers and real literals, comments) 2016-12-08 18:11:56 +03:00
Zachary Yedidia
e1d231baa3 Merge pull request #478 from NicolaiSoeborg/master
Add syntax highlighting for Solidity
2016-12-07 21:30:54 -05:00
Zachary Yedidia
8436e2866f Merge pull request #481 from sirikid/syntax-fix
Simple fix for Pascal syntax highlighting
2016-12-07 21:30:05 -05:00
Zachary Yedidia
3ee87e8767 Merge pull request #480 from Theodus/master
improve pony syntax
2016-12-07 21:30:00 -05:00
Ivan Sokolov
11e9419258 Simple fix for Pascal syntax highlighting 2016-12-08 05:03:00 +03:00
theodus
cb7fe94b04 improve pony syntax 2016-12-07 17:09:24 -05:00
Zachary Yedidia
3f01f73ea9 Give error message if input is a directory
Fixes #479
2016-12-07 10:28:03 -05:00
Nicolai
c35650e51a Add syntax highlighting for Solidity 2016-12-06 21:52:37 +01:00
Nicolai
b0813f12e6 Merge remote-tracking branch 'refs/remotes/zyedidia/master' 2016-12-06 21:51:33 +01:00
51 changed files with 702 additions and 253 deletions

View File

@@ -3,30 +3,31 @@
VERSION = $(shell go run tools/build-version.go)
HASH = $(shell git rev-parse --short HEAD)
DATE = $(shell go run tools/build-date.go)
ADDITIONAL_GO_LINKER_FLAGS = $(shell go run tools/info-plist.go "$(VERSION)")
GOBIN ?= $(GOPATH)/bin
# Builds micro after checking dependencies but without updating the runtime
build: deps
go build -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" ./cmd/micro
go build -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
# Builds micro after building the runtime and checking dependencies
build-all: runtime build
# Builds micro without checking for dependencies
build-quick:
go build -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" ./cmd/micro
go build -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
# Same as 'build' but installs to $GOBIN afterward
install: deps
go install -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" ./cmd/micro
go install -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
# Same as 'build-all' but installs to $GOBIN afterward
install-all: runtime install
# Same as 'build-quick' but installs to $GOBIN afterward
install-quick:
go install -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" ./cmd/micro
go install -ldflags "-s -w -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
# Checks for dependencies
deps:

View File

@@ -36,7 +36,7 @@ You can also check out the website for Micro at https://micro-editor.github.io.
* Micro has a built-in plugin manager to automatically install, remove, and update all your plugins
* Persistent undo
* Automatic linting and error notifications
* Syntax highlighting (for over [75 languages](runtime/syntax)!)
* Syntax highlighting (for over [90 languages](runtime/syntax)!)
* Colorscheme support
* By default, micro comes with 16, 256, and true color themes.
* True color support (set the `MICRO_TRUECOLOR` env variable to 1 to enable it)
@@ -67,14 +67,20 @@ and you'll see all the stable releases with the corresponding binaries.
If you'd like to see more information after installing micro, run `micro -version`.
### Homebrew
### Package Managers
You can also install micro using Homebrew on Mac:
You can install micro using Homebrew on Mac:
```
brew install micro
```
On Windows, you can install micro through Chocolatey:
```
choco install micro
```
### Building from source
If your operating system does not have a binary release, but does run Go, you can build from source.
@@ -107,7 +113,7 @@ If you don't have xclip or xsel, micro will use an internal clipboard for copy a
If you open micro and it doesn't seem like syntax highlighting is working, this is probably because
you are using a terminal which does not support 256 color. Try changing the colorscheme to `simple`
by running `> set colorscheme simple`.
by pressing CtrlE in micro and typing `set colorscheme simple`.
If you are using the default Ubuntu terminal, to enable 256 make sure your `TERM` variable is set
to `xterm-256color`.

View File

@@ -13,7 +13,7 @@ import (
// PreActionCall executes the lua pre callback if possible
func PreActionCall(funcName string, view *View) bool {
executeAction := true
for _, pl := range loadedPlugins {
for pl := range loadedPlugins {
ret, err := Call(pl+".pre"+funcName, view)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)
@@ -29,7 +29,7 @@ func PreActionCall(funcName string, view *View) bool {
// PostActionCall executes the lua plugin callback if possible
func PostActionCall(funcName string, view *View) bool {
relocate := true
for _, pl := range loadedPlugins {
for pl := range loadedPlugins {
ret, err := Call(pl+".on"+funcName, view)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)
@@ -463,7 +463,8 @@ func (v *View) InsertNewline(usePlugin bool) bool {
v.Cursor.Right()
}
if IsSpacesOrTabs(v.Buf.Line(v.Cursor.Y - 1)) {
// Remove the whitespaces if keepautoindent setting is off
if IsSpacesOrTabs(v.Buf.Line(v.Cursor.Y - 1)) && !v.Buf.Settings["keepautoindent"].(bool) {
line := v.Buf.Line(v.Cursor.Y - 1)
v.Buf.Remove(Loc{0, v.Cursor.Y - 1}, Loc{Count(line), v.Cursor.Y - 1})
}
@@ -851,7 +852,7 @@ func (v *View) Copy(usePlugin bool) bool {
}
if v.Cursor.HasSelection() {
clipboard.WriteAll(v.Cursor.GetSelection(), "clipboard")
v.Cursor.CopySelection("clipboard")
v.freshClip = true
messenger.Message("Copied selection")
}
@@ -902,7 +903,7 @@ func (v *View) Cut(usePlugin bool) bool {
}
if v.Cursor.HasSelection() {
clipboard.WriteAll(v.Cursor.GetSelection(), "clipboard")
v.Cursor.CopySelection("clipboard")
v.Cursor.DeleteSelection()
v.Cursor.ResetSelection()
v.freshClip = true
@@ -1472,7 +1473,7 @@ func (v *View) AddTab(usePlugin bool) bool {
tab := NewTabFromView(NewView(NewBuffer(strings.NewReader(""), "")))
tab.SetNum(len(tabs))
tabs = append(tabs, tab)
curTab++
curTab = len(tabs) - 1
if len(tabs) == 2 {
for _, t := range tabs {
for _, v := range t.views {
@@ -1651,7 +1652,7 @@ func (v *View) PlayMacro(usePlugin bool) bool {
v.Buf.Insert(v.Cursor.Loc, string(t))
v.Cursor.Right()
for _, pl := range loadedPlugins {
for pl := range loadedPlugins {
_, err := Call(pl+".onRune", string(t), v)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)

View File

@@ -41,6 +41,7 @@ var bindingActions = map[string]func(*View, bool) bool{
"Delete": (*View).Delete,
"InsertTab": (*View).InsertTab,
"Save": (*View).Save,
"SaveAs": (*View).SaveAs,
"Find": (*View).Find,
"FindNext": (*View).FindNext,
"FindPrevious": (*View).FindPrevious,
@@ -346,8 +347,19 @@ func BindKey(k, v string) {
if v == "ToggleHelp" {
helpBinding = k
}
if helpBinding == k && v != "ToggleHelp" {
helpBinding = ""
}
actionNames := strings.Split(v, ",")
if actionNames[0] == "UnbindKey" {
delete(bindings, key)
if len(actionNames) == 1 {
actionNames = make([]string, 0, 0)
} else {
actionNames = append(actionNames[:0], actionNames[1:]...)
}
}
actions := make([]func(*View, bool) bool, 0, len(actionNames))
for _, actionName := range actionNames {
actions = append(actions, findAction(actionName))

View File

@@ -9,10 +9,13 @@ import (
"os/exec"
"os/signal"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
"unicode/utf8"
"github.com/mitchellh/go-homedir"
)
// Buffer stores the text for files that are loaded into the text editor
@@ -279,14 +282,27 @@ func (b *Buffer) Serialize() error {
func (b *Buffer) SaveAs(filename string) error {
b.FindFileType()
b.UpdateRules()
b.Path = filename
str := b.String()
dir, _ := homedir.Dir()
b.Path = strings.Replace(filename, "~", dir, 1)
if b.Settings["rmtrailingws"].(bool) {
r, _ := regexp.Compile(`[ \t]+$`)
for lineNum, line := range b.Lines(0, b.NumLines) {
indices := r.FindStringIndex(line)
if indices == nil {
continue
}
startLoc := Loc{indices[0], lineNum}
b.deleteToEnd(startLoc)
}
b.Cursor.Relocate()
}
if b.Settings["eofnewline"].(bool) {
end := b.End()
if b.RuneAt(Loc{end.X - 1, end.Y}) != '\n' {
b.Insert(end, "\n")
}
}
str := b.String()
data := []byte(str)
err := ioutil.WriteFile(filename, data, 0644)
if err == nil {
@@ -359,6 +375,11 @@ func (b *Buffer) remove(start, end Loc) string {
b.Update()
return sub
}
func (b *Buffer) deleteToEnd(start Loc) {
b.IsModified = true
b.LineArray.DeleteToEnd(start)
b.Update()
}
// Start returns the location of the first character in the buffer
func (b *Buffer) Start() Loc {

View File

@@ -44,7 +44,7 @@ func LoadColorscheme(colorschemeName string) {
TermMessage(colorschemeName, "is not a valid colorscheme")
} else {
if data, err := file.Data(); err != nil {
fmt.Println("Error loading colorscheme:", err)
TermMessage("Error loading colorscheme:", err)
} else {
colorscheme = ParseColorscheme(string(data))

View File

@@ -133,12 +133,10 @@ func PluginCmd(args []string) {
removed := ""
for _, plugin := range args[1:] {
// check if the plugin exists.
for _, lp := range loadedPlugins {
if lp == plugin {
UninstallPlugin(plugin)
removed += plugin + " "
continue
}
if _, ok := loadedPlugins[plugin]; ok {
UninstallPlugin(plugin)
removed += plugin + " "
continue
}
}
if !IsSpaces(removed) {
@@ -333,7 +331,7 @@ func NewTab(args []string) {
tab := NewTabFromView(NewView(NewBuffer(file, filename)))
tab.SetNum(len(tabs))
tabs = append(tabs, tab)
curTab++
curTab = len(tabs) - 1
if len(tabs) == 2 {
for _, t := range tabs {
for _, v := range t.views {

View File

@@ -29,6 +29,15 @@ func (c *Cursor) Goto(b Cursor) {
c.OrigSelection, c.CurSelection = b.OrigSelection, b.CurSelection
}
// CopySelection copies the user's selection to either "primary" or "clipboard"
func (c *Cursor) CopySelection(target string) {
if c.HasSelection() {
if target != "primary" || c.buf.Settings["useprimary"].(bool) {
clipboard.WriteAll(c.GetSelection(), target)
}
}
}
// ResetSelection resets the user's selection
func (c *Cursor) ResetSelection() {
c.CurSelection[0] = c.buf.Start()
@@ -38,19 +47,11 @@ func (c *Cursor) ResetSelection() {
// SetSelectionStart sets the start of the selection
func (c *Cursor) SetSelectionStart(pos Loc) {
c.CurSelection[0] = pos
// Copy to primary clipboard for linux
if c.HasSelection() {
clipboard.WriteAll(c.GetSelection(), "primary")
}
}
// SetSelectionEnd sets the end of the selection
func (c *Cursor) SetSelectionEnd(pos Loc) {
c.CurSelection[1] = pos
// Copy to primary clipboard for linux
if c.HasSelection() {
clipboard.WriteAll(c.GetSelection(), "primary")
}
}
// HasSelection returns whether or not the user has selected anything

View File

@@ -117,7 +117,7 @@ func (eh *EventHandler) Execute(t *TextEvent) {
}
eh.UndoStack.Push(t)
for _, pl := range loadedPlugins {
for pl := range loadedPlugins {
ret, err := Call(pl+".onBeforeTextEvent", t)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"io"
"os/exec"
"strings"
)
// Jobs are the way plugins can run processes in the background
@@ -43,10 +42,7 @@ 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 {
split := strings.Split(cmd, " ")
cmdArgs := split[1:]
cmdName := split[0]
return JobSpawn(cmdName, cmdArgs, onStdout, onStderr, onExit, userargs...)
return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
}
// JobSpawn starts a process with args in the background with the given callbacks

View File

@@ -87,36 +87,68 @@ func (m *Messenger) getBuffer() *Buffer {
// Message sends a message to the user
func (m *Messenger) Message(msg ...interface{}) {
m.message = fmt.Sprint(msg...)
m.style = defStyle
displayMessage := fmt.Sprint(msg...)
// only display a new message if there isn't an active prompt
// this is to prevent overwriting an existing prompt to the user
if m.hasPrompt == false {
// if there is no active prompt then style and display the message as normal
m.message = displayMessage
if _, ok := colorscheme["message"]; ok {
m.style = colorscheme["message"]
m.style = defStyle
if _, ok := colorscheme["message"]; ok {
m.style = colorscheme["message"]
}
m.hasMessage = true
}
m.AddLog(m.message)
m.hasMessage = true
// add the message to the log regardless of active prompts
m.AddLog(displayMessage)
}
// Error sends an error message to the user
func (m *Messenger) Error(msg ...interface{}) {
buf := new(bytes.Buffer)
fmt.Fprint(buf, msg...)
m.message = buf.String()
m.style = defStyle.
Foreground(tcell.ColorBlack).
Background(tcell.ColorMaroon)
if _, ok := colorscheme["error-message"]; ok {
m.style = colorscheme["error-message"]
// only display a new message if there isn't an active prompt
// this is to prevent overwriting an existing prompt to the user
if m.hasPrompt == false {
// if there is no active prompt then style and display the message as normal
m.message = buf.String()
m.style = defStyle.
Foreground(tcell.ColorBlack).
Background(tcell.ColorMaroon)
if _, ok := colorscheme["error-message"]; ok {
m.style = colorscheme["error-message"]
}
m.hasMessage = true
}
m.AddLog(m.message)
// add the message to the log regardless of active prompts
m.AddLog(buf.String())
}
func (m *Messenger) PromptText(msg ...interface{}) {
displayMessage := fmt.Sprint(msg...)
// if there is no active prompt then style and display the message as normal
m.message = displayMessage
m.style = defStyle
if _, ok := colorscheme["message"]; ok {
m.style = colorscheme["message"]
}
m.hasMessage = true
// add the message to the log regardless of active prompts
m.AddLog(displayMessage)
}
// YesNoPrompt asks the user a yes or no question (waits for y or n) and returns the result
func (m *Messenger) YesNoPrompt(prompt string) (bool, bool) {
m.hasPrompt = true
m.Message(prompt)
m.PromptText(prompt)
_, h := screen.Size()
for {
@@ -151,7 +183,7 @@ func (m *Messenger) YesNoPrompt(prompt string) (bool, bool) {
// LetterPrompt gives the user a prompt and waits for a one letter response
func (m *Messenger) LetterPrompt(prompt string, responses ...rune) (rune, bool) {
m.hasPrompt = true
m.Message(prompt)
m.PromptText(prompt)
_, h := screen.Size()
for {
@@ -201,7 +233,7 @@ const (
// This function blocks the main loop while waiting for input
func (m *Messenger) Prompt(prompt, placeholder, historyType string, completionTypes ...Completion) (string, bool) {
m.hasPrompt = true
m.Message(prompt)
m.PromptText(prompt)
if _, ok := m.history[historyType]; !ok {
m.history[historyType] = []string{""}
} else {

View File

@@ -11,7 +11,7 @@ import (
"time"
"github.com/go-errors/errors"
"github.com/layeh/gopher-luar"
"layeh.com/gopher-luar"
"github.com/mattn/go-isatty"
"github.com/mitchellh/go-homedir"
"github.com/yuin/gopher-lua"
@@ -97,11 +97,16 @@ func LoadInput() []*Buffer {
if _, e := os.Stat(filename); e == nil {
// If it exists we load it into a buffer
input, err = os.Open(filename)
stat, _ := input.Stat()
defer input.Close()
if err != nil {
TermMessage(err)
continue
}
if stat.IsDir() {
TermMessage("Cannot read", filename, "because it is a directory")
continue
}
}
// If the file didn't exist, input will be empty, and we'll open an empty buffer
if input != nil {
@@ -380,7 +385,7 @@ func main() {
for _, v := range t.views {
v.Buf.FindFileType()
v.Buf.UpdateRules()
for _, pl := range loadedPlugins {
for pl := range loadedPlugins {
_, err := Call(pl+".onViewOpen", v)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)

View File

@@ -6,11 +6,11 @@ import (
"os"
"strings"
"github.com/layeh/gopher-luar"
"layeh.com/gopher-luar"
"github.com/yuin/gopher-lua"
)
var loadedPlugins []string
var loadedPlugins map[string]string
// Call calls the lua function 'function'
// If it does not exist nothing happens, if there is an error,
@@ -112,32 +112,39 @@ func LuaFunctionJob(function string) func(string, ...string) {
}
}
// luaPluginName convert a human-friendly plugin name into a valid lua variable name.
func luaPluginName(name string) string {
return strings.Replace(name, "-", "_", -1)
}
// LoadPlugins loads the pre-installed plugins and the plugins located in ~/.config/micro/plugins
func LoadPlugins() {
loadedPlugins = make(map[string]string)
for _, plugin := range ListRuntimeFiles(RTPlugin) {
alreadyExists := false
pluginName := plugin.Name()
for _, pl := range loadedPlugins {
if pl == pluginName {
alreadyExists = true
break
}
if _, ok := loadedPlugins[pluginName]; ok {
continue
}
if !alreadyExists {
data, err := plugin.Data()
if err != nil {
TermMessage("Error loading plugin: " + pluginName)
continue
}
pluginDef := "\nlocal P = {}\n" + pluginName + " = P\nsetmetatable(" + pluginName + ", {__index = _G})\nsetfenv(1, P)\n"
if err := L.DoString(pluginDef + string(data)); err != nil {
TermMessage(err)
continue
}
loadedPlugins = append(loadedPlugins, pluginName)
data, err := plugin.Data()
if err != nil {
TermMessage("Error loading plugin: " + pluginName)
continue
}
pluginLuaName := luaPluginName(pluginName)
pluginDef := "\nlocal P = {}\n" + pluginLuaName + " = P\nsetmetatable(" + pluginLuaName + ", {__index = _G})\nsetfenv(1, P)\n"
if err := L.DoString(pluginDef + string(data)); err != nil {
TermMessage(err)
continue
}
loadedPlugins[pluginName] = pluginLuaName
}
if _, err := os.Stat(configDir + "/init.lua"); err == nil {
@@ -146,6 +153,6 @@ func LoadPlugins() {
if err := L.DoString(pluginDef + string(data)); err != nil {
TermMessage(err)
}
loadedPlugins = append(loadedPlugins, "init")
loadedPlugins["init"] = "init"
}
}

View File

@@ -358,8 +358,8 @@ func GetInstalledVersions(withCore bool) PluginVersions {
result = append(result, newStaticPluginVersion(CorePluginName, Version))
}
for _, name := range loadedPlugins {
version := GetInstalledPluginVersion(name)
for name, lpname := range loadedPlugins {
version := GetInstalledPluginVersion(lpname)
if pv := newStaticPluginVersion(name, version); pv != nil {
result = append(result, pv)
}
@@ -561,7 +561,9 @@ func (pv PluginVersions) install() {
func UninstallPlugin(name string) {
if err := os.RemoveAll(filepath.Join(configDir, "plugins", name)); err != nil {
messenger.Error(err)
return
}
delete(loadedPlugins, name)
}
// Install installs the plugin
@@ -582,7 +584,9 @@ func (pl PluginPackage) Install() {
func UpdatePlugins(plugins []string) {
// if no plugins are specified, update all installed plugins.
if len(plugins) == 0 {
plugins = loadedPlugins
for name := range loadedPlugins {
plugins = append(plugins, name)
}
}
messenger.AddLog("Checking for plugin updates")

File diff suppressed because one or more lines are too long

View File

@@ -27,8 +27,8 @@ func BeginSearch(searchStr string) {
searching = true
messenger.response = searchStr
messenger.cursorx = Count(searchStr)
messenger.hasPrompt = true
messenger.Message("Find: ")
messenger.hasPrompt = true
}
// EndSearch stops the current search

View File

@@ -175,31 +175,34 @@ func GetOption(name string) interface{} {
// Note that colorscheme is a global only option
func DefaultGlobalSettings() map[string]interface{} {
return map[string]interface{}{
"autoindent": true,
"autosave": false,
"colorcolumn": float64(0),
"colorscheme": "default",
"cursorline": true,
"eofnewline": false,
"ignorecase": false,
"indentchar": " ",
"infobar": true,
"ruler": true,
"savecursor": false,
"saveundo": false,
"scrollspeed": float64(2),
"scrollmargin": float64(3),
"softwrap": false,
"splitRight": true,
"splitBottom": true,
"statusline": true,
"syntax": true,
"tabsize": float64(4),
"tabstospaces": false,
"autoindent": true,
"keepautoindent": false,
"autosave": false,
"colorcolumn": float64(0),
"colorscheme": "default",
"cursorline": true,
"eofnewline": false,
"rmtrailingws": false,
"ignorecase": false,
"indentchar": " ",
"infobar": true,
"ruler": true,
"savecursor": false,
"saveundo": false,
"scrollspeed": float64(2),
"scrollmargin": float64(3),
"softwrap": false,
"splitRight": true,
"splitBottom": true,
"statusline": true,
"syntax": true,
"tabsize": float64(4),
"tabstospaces": false,
"pluginchannels": []string{
"https://raw.githubusercontent.com/micro-editor/plugin-channel/master/channel.json",
},
"pluginrepos": []string{},
"useprimary": true,
}
}
@@ -207,26 +210,29 @@ func DefaultGlobalSettings() map[string]interface{} {
// Note that filetype is a local only option
func DefaultLocalSettings() map[string]interface{} {
return map[string]interface{}{
"autoindent": true,
"autosave": false,
"colorcolumn": float64(0),
"cursorline": true,
"eofnewline": false,
"filetype": "Unknown",
"ignorecase": false,
"indentchar": " ",
"ruler": true,
"savecursor": false,
"saveundo": false,
"scrollspeed": float64(2),
"scrollmargin": float64(3),
"softwrap": false,
"splitRight": true,
"splitBottom": true,
"statusline": true,
"syntax": true,
"tabsize": float64(4),
"tabstospaces": false,
"autoindent": true,
"keepautoindent": false,
"autosave": false,
"colorcolumn": float64(0),
"cursorline": true,
"eofnewline": false,
"rmtrailingws": false,
"filetype": "Unknown",
"ignorecase": false,
"indentchar": " ",
"ruler": true,
"savecursor": false,
"saveundo": false,
"scrollspeed": float64(2),
"scrollmargin": float64(3),
"softwrap": false,
"splitRight": true,
"splitBottom": true,
"statusline": true,
"syntax": true,
"tabsize": float64(4),
"tabstospaces": false,
"useprimary": true,
}
}

View File

@@ -36,9 +36,12 @@ func (sline *Statusline) Display() {
// Add the filetype
file += " " + sline.view.Buf.FileType()
rightText := helpBinding + " for help "
if sline.view.Type == vtHelp {
rightText = helpBinding + " to close help "
rightText := ""
if len(helpBinding) > 0 {
rightText = helpBinding + " for help "
if sline.view.Type == vtHelp {
rightText = helpBinding + " to close help "
}
}
statusLineStyle := defStyle.Reverse(true)

View File

@@ -174,7 +174,7 @@ func StringWidth(str string, tabsize int) int {
switch ch {
case '\t':
ts := tabsize - (lineIdx % tabsize)
sw += ts - 1
sw += ts
lineIdx += ts
case '\n':
lineIdx = 0

View File

@@ -120,7 +120,7 @@ func NewViewWidthHeight(buf *Buffer, w, h int) *View {
v.Height--
}
for _, pl := range loadedPlugins {
for pl := range loadedPlugins {
_, err := Call(pl+".onViewOpen", v)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)
@@ -304,6 +304,9 @@ func (v *View) VSplitIndex(buf *Buffer, splitIndex int) {
// GetSoftWrapLocation gets the location of a visual click on the screen and converts it to col,line
func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
if !v.Buf.Settings["softwrap"].(bool) {
if vy >= v.Buf.NumLines {
vy = v.Buf.NumLines - 1
}
vx = v.Cursor.GetCharPosInLine(vy, vx)
return vx, vy
}
@@ -311,6 +314,9 @@ func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
screenX, screenY := 0, v.Topline
for lineN := v.Topline; lineN < v.Bottomline(); lineN++ {
line := v.Buf.Line(lineN)
if lineN >= v.Buf.NumLines {
return 0, v.Buf.NumLines - 1
}
colN := 0
for _, ch := range line {
@@ -418,9 +424,6 @@ func (v *View) MoveToMouseClick(x, y int) {
v.ScrollDown(1)
y = v.Height + v.Topline - 1
}
if y >= v.Buf.NumLines {
y = v.Buf.NumLines - 1
}
if y < 0 {
y = 0
}
@@ -487,7 +490,7 @@ func (v *View) HandleEvent(event tcell.Event) {
v.Buf.Insert(v.Cursor.Loc, string(e.Rune()))
v.Cursor.Right()
for _, pl := range loadedPlugins {
for pl := range loadedPlugins {
_, err := Call(pl+".onRune", string(e.Rune()), v)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)
@@ -529,6 +532,7 @@ func (v *View) HandleEvent(event tcell.Event) {
v.doubleClick = false
v.Cursor.SelectLine()
v.Cursor.CopySelection("primary")
} else {
// Double click
v.lastClickTime = time.Now()
@@ -537,6 +541,7 @@ func (v *View) HandleEvent(event tcell.Event) {
v.tripleClick = false
v.Cursor.SelectWord()
v.Cursor.CopySelection("primary")
}
} else {
v.doubleClick = false
@@ -556,6 +561,7 @@ func (v *View) HandleEvent(event tcell.Event) {
v.Cursor.AddWordToSelection()
} else {
v.Cursor.SetSelectionEnd(v.Cursor.Loc)
v.Cursor.CopySelection("primary")
}
}
case tcell.Button2:
@@ -576,6 +582,7 @@ func (v *View) HandleEvent(event tcell.Event) {
if !v.doubleClick && !v.tripleClick {
v.MoveToMouseClick(x, y)
v.Cursor.SetSelectionEnd(v.Cursor.Loc)
v.Cursor.CopySelection("primary")
}
v.mouseReleased = true
}
@@ -810,8 +817,16 @@ func (v *View) DisplayView() {
if v.Buf.Settings["softwrap"].(bool) {
if screenX-v.x >= v.Width {
screenY++
x := 0
if hasGutterMessages {
v.drawCell(v.x+x, screenY, ' ', nil, defStyle)
x++
v.drawCell(v.x+x, screenY, ' ', nil, defStyle)
x++
}
for i := 0; i < v.lineNumOffset; i++ {
screen.SetContent(v.x+i, screenY, ' ', nil, lineNumStyle)
screen.SetContent(v.x+i+x, screenY, ' ', nil, lineNumStyle)
}
screenX = v.x + v.lineNumOffset
}

View File

@@ -4,6 +4,7 @@ color-link identifier "#F9EE98,#1D1F21"
color-link constant "#FF73FD,#1D1F21"
color-link constant.string "#A8FF60,#1D1F21"
color-link statement "#96CBFE,#1D1F21"
color-link symbol "#96CBFE,#1DF121"
color-link preproc "#62B1FE,#1D1F21"
color-link type "#C6C5FE,#1D1F21"
color-link special "#A6E22E,#1D1F21"

View File

@@ -5,6 +5,7 @@ color-link constant.string "136,231"
color-link constant.number "131,231"
color-link identifier "133,231"
color-link statement "32,231"
color-link symbol "32,231"
color-link preproc "28,231"
color-link type "61,231"
color-link special "167,231"

View File

@@ -6,6 +6,7 @@ color-link constant "#AE81FF,#282828"
color-link constant.string "#E6DB74,#282828"
color-link constant.string.char "#BDE6AD,#282828"
color-link statement "#F92672,#282828"
color-link symbol "#F92672,#282828"
color-link preproc "#CB4B16,#282828"
color-link type "#66D9EF,#282828"
color-link special "#A6E22E,#282828"

View File

@@ -0,0 +1,19 @@
color-link default "#ebdbb2,#282828"
color-link comment "#928374,#282828"
color-link symbol "#d79921,#282828"
color-link constant "#d3869b,#282828"
color-link constant.string "#b8bb26,#282828"
color-link constant.string.char "#b8bb26,#282828"
color-link identifier "#8ec07c,#282828"
color-link statement "#fb4934,#282828"
color-link preproc "#fb4934,235"
color-link type "#fb4934,#282828"
color-link special "#d79921,#282828"
color-link underlined "underline #282828"
color-link error "#9d0006,#282828"
color-link gutter-error "#fb4934,#282828"
color-link gutter-warning "#d79921,#282828"
color-link line-number "#665c54,#282828"
color-link current-line-number "#665c54,#3c3836"
color-link cursor-line "#3c3836"
color-link color-column "#79740e"

View File

@@ -4,6 +4,7 @@ color-link constant "175,235"
color-link constant.string "142,235"
color-link identifier "109,235"
color-link statement "124,235"
color-link symbol "124,235"
color-link preproc "72,235"
color-link type "214,235"
color-link special "172,235"

View File

@@ -5,6 +5,7 @@ color-link constant "#AE81FF,#282828"
color-link constant.string "#E6DB74,#282828"
color-link constant.string.char "#BDE6AD,#282828"
color-link statement "#F92672,#282828"
color-link symbol "#F92672,#282828"
color-link preproc "#CB4B16,#282828"
color-link type "#66D9EF,#282828"
color-link special "#A6E22E,#282828"

View File

@@ -2,6 +2,7 @@ color-link comment "blue"
color-link constant "red"
color-link identifier "cyan"
color-link statement "yellow"
color-link symbol "yellow"
color-link preproc "magenta"
color-link type "green"
color-link special "magenta"

View File

@@ -3,6 +3,7 @@ color-link comment "#586E75,#002833"
color-link identifier "#268BD2,#002833"
color-link constant "#2AA198,#002833"
color-link statement "#859900,#002833"
color-link symbol "#859900,#002833"
color-link preproc "#CB4B16,#002833"
color-link type "#B58900,#002833"
color-link special "#DC322F,#002833"

View File

@@ -2,6 +2,7 @@ color-link comment "brightgreen"
color-link constant "cyan"
color-link identifier "blue"
color-link statement "green"
color-link symbol "green"
color-link preproc "brightred"
color-link type "yellow"
color-link special "red"

View File

@@ -5,6 +5,7 @@ color-link constant.number "116,237"
color-link constant "181,237"
color-link identifier "223,237"
color-link statement "223,237"
color-link symbol "223,237"
color-link preproc "223,237"
color-link type "187,237"
color-link special "181,237"

View File

@@ -19,17 +19,17 @@ Micro comes with a number of colorschemes by default. Here is the list:
* zenburn: The 'zenburn' colorscheme and works well with 256 color terminals
* solarized: this is the solarized colorscheme.
* solarized: this is the solarized colorscheme.
You should have the solarized color palette in your terminal to use it.
* solarized-tc: this is the solarized colorscheme for true color; just
make sure your terminal supports true color before using it and that the
* solarized-tc: this is the solarized colorscheme for true color; just
make sure your terminal supports true color before using it and that the
MICRO_TRUECOLOR environment variable is set to 1 before starting micro.
* atom-dark-tc: this colorscheme is based off of Atom's "dark" colorscheme.
It requires true color to look good.
To enable one of these colorschemes just run the command `set colorscheme solarized`.
To enable one of these colorschemes just press CtrlE in micro and type `set colorscheme solarized`.
(or whichever one you choose).
---
@@ -95,6 +95,7 @@ Here is a list of the colorscheme groups that you can use:
* identifier
* constant
* statement
* symbol
* preproc
* type
* special

View File

@@ -115,6 +115,11 @@ and quit you can bind it like so:
}
```
# Unbinding keys
It is also possible to disable any of the default key bindings by use of the
`UnbindKey` action in the user's `bindings.json` file.
# Bindable actions and bindable keys
The list of default keybindings contains most of the possible actions and keys
@@ -196,6 +201,7 @@ HSplit
PreviousSplit
ToggleMacro
PlayMacro
UnbindKey
```
Here is the list of all possible keys you can bind:

View File

@@ -32,6 +32,10 @@ Here are the options that you can set:
default value: `false`
* `rmtrailingws`: micro will automatically trim trailing whitespaces at eol.
default value: `false`
* `tabsize`: sets the tab size to `option`
default value: `4`
@@ -99,17 +103,17 @@ Here are the options that you can set:
* `softwrap`: should micro wrap lines that are too long to fit on the screen
default value: `off`
default value: `off`
* `splitRight`: when a vertical split is created, should it be created to the right of
the current split?
default value: `on`
default value: `on`
* `splitRight`: when a horizontal split is created, should it be created below the
* `splitBottom`: when a horizontal split is created, should it be created below the
current split?
default value: `on`
default value: `on`
* `autosave`: micro will save the buffer every 8 seconds automatically.
Micro also will automatically save and quit when you exit without asking.
@@ -123,13 +127,18 @@ Here are the options that you can set:
metadata about the given plugin. See the `Plugin Manager` section of the `plugins` help topic
for more information.
default value: `https://github.com/micro-editor/plugin-channel`
default value: `https://github.com/micro-editor/plugin-channel`
* `pluginrepos`: contains all the 'repositories' micro's plugin manager will search for
plugins in. A repository consists of a `repo.json` file which contains metadata for a
single plugin.
default value: ` `
default value: ` `
* `useprimary` (only useful on Linux): defines whether or not micro will use the primary clipboard to copy selections
in the background. This does not affect the normal clipboard using Ctrl-C and Ctrl-V.
default value: `on`
---

View File

@@ -51,6 +51,12 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
* `messenger`: lets you send messages to the user or create prompts
* `NewBuffer(text, path string) *Buffer`: creates a new buffer from a given reader with a given path
* `GetLeadingWhitespace() bool`: returns the leading whitespace of the given string
* `IsWordChar(str string) bool`: returns whether or not the string is a 'word character'
* `RuneStr(r rune) string`: returns a string containing the given rune
* `Loc(x, y int) Loc`: returns a new `Loc` struct
@@ -67,7 +73,7 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
* `SetOption(option, value string)`: sets the given option to the value. This will
set the option globally, unless it is a local only option.
* `SetLocalOption(option, value string, buffer *Buffer)`: sets the given option to
* `SetLocalOption(option, value string, view *View)`: sets the given option to
the value locally in the given buffer
* `BindKey(key, action string)`: binds `key` to `action`
@@ -88,9 +94,11 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
`waitToClose` bool only applies if `interactive` is true and means that it should wait before
returning to the editor.
* `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a given x, y location.
* `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a given x, y location
* `ByteOffset(loc Loc, buf *Buffer) int`: exactly like `ToCharPos` except it it counts bytes instead of runes.
* `Reload`: (Re)load everything
* `ByteOffset(loc Loc, buf *Buffer) int`: exactly like `ToCharPos` except it it counts bytes instead of runes
* `JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit string, userargs ...string)`:
Starts running the given process in the background. `onStdout` `onStderr` and `onExit`
@@ -99,8 +107,8 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
`userargs` are the arguments which will get passed to the callback functions
* `JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...string)`:
Starts running the given shell command in the background.
This function is a shorthand for `JobSpawn`.
Starts running the given shell command in the background. Note that the command execute
is first parsed by a shell when using this command. It is executed with `sh -c`.
* `JobSend(cmd *exec.Cmd, data string)`: send a string into the stdin of the job process
@@ -130,8 +138,8 @@ If you want a standard prompt, just use `messenger.Prompt(prompt, "", 0)`
# Adding help files, syntax files, or colorschemes in your plugin
You can use the `AddRuntimeFile(name, type, path string)` function to add various kinds of
files to your plugin. For example, if you'd like to add a help topic and to your plugin
called `test`, you would create the `test.md` file for example, and runt the function:
files to your plugin. For example, if you'd like to add a help topic to your plugin
called `test`, you would create a `test.md` file, and call the function:
```lua
AddRuntimeFile("test", "help", "test.md")
@@ -139,6 +147,8 @@ AddRuntimeFile("test", "help", "test.md")
Use `AddRuntimeFilesFromDirectory(name, type, dir, pattern)` to add a number of files
to the runtime.
To read the content of a runtime file use `ReadRuntimeFile(fileType, name string)`
or `ListRuntimeFiles(fileType string)` for all runtime files.
# Autocomplete command arguments

View File

@@ -19,20 +19,28 @@ function runLinter()
temp = os.getenv("TEMP")
end
if ft == "go" then
lint("gobuild", "go build -o " .. devnull, "%f:%l: %m")
lint("golint", "golint " .. CurView().Buf.Path, "%f:%l:%d+: %m")
lint("gobuild", "go", {"build", "-o", devnull}, "%f:%l: %m")
lint("golint", "golint", {CurView().Buf.Path}, "%f:%l:%d+: %m")
elseif ft == "lua" then
lint("luacheck", "luacheck --no-color " .. file, "%f:%l:%d+: %m")
lint("luacheck", "luacheck", {"--no-color", file}, "%f:%l:%d+: %m")
elseif ft == "python" then
lint("pyflakes", "pyflakes " .. file, "%f:%l:.-:? %m")
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 == "c" then
lint("gcc", "gcc -fsyntax-only -Wall -Wextra " .. file, "%f:%l:%d+:.+: %m")
lint("gcc", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
elseif ft == "swift" then
lint("switfc", "xcrun", {"swiftc", 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 == "d" then
lint("dmd", "dmd -color=off -o- -w -wi -c " .. file, "%f%(%l%):.+: %m")
lint("dmd", "dmd", {"-color=off", "-o-", "-w", "-wi", "-c", file}, "%f%(%l%):.+: %m")
elseif ft == "java" then
lint("javac", "javac -d " .. temp .. " " .. file, "%f:%l: error: %m")
lint("javac", "javac", {"-d", temp, file}, "%f:%l: error: %m")
elseif ft == "javascript" then
lint("jshint", "jshint " .. file, "%f: line %l,.+, %m")
lint("jshint", "jshint", {file}, "%f: line %l,.+, %m")
elseif ft == "nim" then
lint("nim", "nim", {"check", "--listFullPaths", "--stdout", "--hints:off", file}, "%f.%l, %d+. %m")
end
end
@@ -44,10 +52,10 @@ function onSave(view)
end
end
function lint(linter, cmd, errorformat)
function lint(linter, cmd, args, errorformat)
CurView():ClearGutterMessages(linter)
JobStart(cmd, "", "", "linter.onExit", linter, errorformat)
JobSpawn(cmd, args, "", "", "linter.onExit", linter, errorformat)
end
function onExit(output, linter, errorformat)

View File

@@ -33,6 +33,7 @@ Here is a list of the files that have been converted to properly use colorscheme
* sh
* git
* tex
* solidity
# License

View File

@@ -1,19 +1,34 @@
syntax "go" "\.go$"
color statement "\b(append|cap|close|complex|copy|delete|imag|len)\b"
color statement "\b(make|new|panic|print|println|protect|real|recover)\b"
color type "\b(u?int(8|16|32|64)?|float(32|64)|complex(64|128))\b"
color type "\b(uintptr|byte|rune|string|interface|bool|map|chan|error)\b"
color statement "\b(package|import|const|var|type|struct|func|go|defer|nil|iota)\b"
color statement "\b(for|range|if|else|case|default|switch|return)\b"
color statement "\b(go|goto|break|continue)\b"
color constant "\b(true|false)\b"
# Conditionals and control flow
color statement "\b(break|case|continue|default|else|for|go|goto|if|range|return|switch)\b"
color statement "\b(package|import|const|var|type|struct|func|go|defer|iota)\b"
color statement "[-+/*=<>!~%&|^]|:="
color constant.number "\b([0-9]+|0x[0-9a-fA-F]*)\b|'.'"
# Types
color special "[a-zA-Z0-9]*\("
color brightyellow "(,|\.)"
color type "\b(u?int(8|16|32|64)?|float(32|64)|complex(64|128))\b"
color type "\b(uintptr|byte|rune|string|interface|bool|map|chan|error)\b"
color constant "\b(true|false|nil)\b"
# Brackets n shit
color statement "(\{|\})"
color statement "(\(|\))"
color statement "(\[|\])"
color statement "!"
color statement ","
# Numbers and strings
color constant.number "\b([0-9]+|0x[0-9a-fA-F]*)\b|'.'"
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
color constant.specialChar "\\[abfnrtv'\"\\]"
color constant.specialChar "\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
color constant.string "`[^`]*`"
color constant.specialChar "\\[abfnrtv'\"\\]"
color constant.specialChar "\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
color constant.string "`[^`]*`"
color constant.specialChar """
color constant.specialChar "'"
# Comments & TODOs
color comment "(^|[[:space:]])//.*"
color comment start="/\*" end="\*/"
color todo "TODO:?"
#color comment start="/\*" end="\*/"
color todo "(TODO|XXX|FIXME):?"

View File

@@ -1,6 +1,6 @@
##############################################################################
#
# Lua syntax highlighting for Nano.
# Lua syntax highlighting for Micro.
#
# Author: Matthew Wild <mwild1 (at) gmail.com>
# License: GPL 2 or later
@@ -14,12 +14,12 @@
# Automatically use for '.lua' files
syntax "lua" ".*\.lua$"
# Operators
color statement ":|\*\*|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\b(not|and|or)\b"
# Statements
color statement "\b(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return)\b"
# Logic
color statement "\b(not|and|or)\b"
# Keywords
color statement "\b(debug|string|math|table|io|coroutine|os|utf8|bit32)\b\."
color statement "\b(_ENV|_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\("
@@ -49,7 +49,7 @@ color statement "(\b(dofile|require|include)|%q|%!|%Q|%r|%x)\b"
color constant.number "\b([0-9]+)\b"
# Symbols
color statement "(\(|\)|\[|\]|\{|\})"
color symbol "(\(|\)|\[|\]|\{|\}|\*\*|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.)"
# Strings
color constant.string "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"

13
runtime/syntax/mail.micro Normal file
View File

@@ -0,0 +1,13 @@
syntax "mail" "(.*/mutt-.*|\.eml)$"
header "^From .* \d+:\d+:\d+ \d+"
color yellow "^From .*"
color identifier "^[^[:space:]]+:"
color preproc "^List-(Id|Archive|Subscribe|Unsubscribe|Post|Help):"
color constant "^(To|From):"
color constant.string "^Subject:.*"
color statement "<?[^@[:space:]]+@[^[:space:]]+>?"
color default start="^\n\n" end=".*"
color comment "^>.*$"

View File

@@ -1,10 +1,13 @@
# Micro syntax by <nickolay02@inbox.ru>
syntax "micro" "\.(micro)$"
color statement "\b(syntax|color|color-link)\b"
color statement "\b(syntax|color(-link)?)\b"
color statement "\b(start=|end=)\b"
color identifier "\b(default|comment|identifier|constant|constant|string|constant|number|statement|preproc|type|special|underlined|error|todo|statusline|indent-char|line=number|gutter-error|gutter-warning|cursor-line)\b"
color identifier "\b(default|comment|symbol|identifier|constant(.string(.char)?|.number)?|statement|preproc|type|special|underlined|error|todo|statusline|indent-char|(current-)?line-number|gutter-error|gutter-warning|cursor-line|color-column)\b"
color constant.number "\b(|h|A|0x)+[0-9]+(|h|A)+\b"
color constant.number "\b0x[0-9 a-f A-F]+\b"
color comment "#.*$"
color constant.string ""(\\.|[^"])*""
color comment "#.*"
color constant.number "#[0-9 A-F a-f]+"

28
runtime/syntax/nim.micro Normal file
View File

@@ -0,0 +1,28 @@
syntax "nim" "\.nim$"
color preproc "[\{\|]\b(atom|lit|sym|ident|call|lvalue|sideeffect|nosideeffect|param|genericparam|module|type|let|var|const|result|proc|method|iterator|converter|macro|template|field|enumfield|forvar|label|nk[a-zA-Z]+|alias|noalias)\b[\}\|]"
color statement "\b(addr|and|as|asm|atomic|bind|block|break|case|cast|concept|const|continue|converter|defer|discard|distinct|div|do|elif|else|end|enum|except|export|finally|for|from|func|generic|if|import|in|include|interface|is|isnot|iterator|let|macro|method|mixin|mod|nil|not|notin|object|of|or|out|proc|ptr|raise|ref|return|shl|shr|static|template|try|tuple|type|using|var|when|while|with|without|xor|yield)\b"
color statement "\b(deprecated|noSideEffect|constructor|destructor|override|procvar|compileTime|noReturn|acyclic|final|shallow|pure|asmNoStackFrame|error|fatal|warning|hint|line|linearScanEnd|computedGoto|unroll|immediate|checks|boundsChecks|overflowChecks|nilChecks|assertations|warnings|hints|optimization|patterns|callconv|push|pop|global|pragma|experimental|bitsize|volatile|noDecl|header|incompleteStruct|compile|link|passC|passL|emit|importc|importcpp|importobjc|codegenDecl|injectStmt|intdefine|strdefine|varargs|exportc|extern|bycopy|byref|union|packed|unchecked|dynlib|cdecl|thread|gcsafe|threadvar|guard|locks|compileTime)\b"
color statement "[=\+\-\*/<>@\$~&%\|!\?\^\.:\\]+"
color special "\{\." "\.\}" "\[\." "\.\]" "\(\." "\.\)" ";" "," "`"
color statement "\.\."
color type "\b(int|cint|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float|float32|float64|bool|char|enum|string|cstring|array|openarray|seq|varargs|tuple|object|set|void|auto|cshort|range|nil|T|untyped|typedesc)\b"
color type "'[iI](8|16|32|64)?\b" "'[uU](8|16|32|64)?\b" "'[fF](32|64|128)?\b" "'[dD]\b"
color constant.number "\b[0-9]+\b"
color constant.number "\b0[xX][0-9][0-9_]+\b"
color constant.number "\b0[ocC][0-7][0-7_]+\b"
color constant.number "\b0[bB][01][01_]+\b"
color constant.number "\b[0-9_]((\.?)[0-9_]+)?[eE][+\-][0-9][0-9_]+\b"
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
color comment "[[:space:]]*#.*$"
color comment start="\#\[" end="\]\#"
color todo "(TODO|FIXME|XXX):?"

View File

@@ -1,25 +1,20 @@
syntax "ocaml" "\.mli?$"
#uid
color red "\<[A-Z][0-9a-z_]{2,}\>"
#declarations
color green "\<(let|val|method|in|and|rec|private|virtual|constraint)\>"
#structure items
color red "\<(type|open|class|module|exception|external)\>"
#patterns
color blue "\<(fun|function|functor|match|try|with)\>"
#patterns-modifiers
color yellow "\<(as|when|of)\>"
#conditions
color cyan "\<(if|then|else)\>"
#blocs
color magenta "\<(begin|end|object|struct|sig|for|while|do|done|to|downto)\>"
#constantes
color green "\<(true|false)\>"
#modules/classes
color green "\<(include|inherit|initializer)\>"
#expr modifiers
color yellow "\<(new|ref|mutable|lazy|assert|raise)\>"
#comments
color white start="\(\*" end="\*\)"
#strings (no multiline handling yet)
color brightblack ""[^\"]*""
# Numbers
## Integers
### Binary
color constant.number "-?0[bB][01][01_]*"
### Octal
color constant.number "-?0[oO][0-7][0-7_]*"
### Decimal
color constant.number "-?\d[\d_]*"
### Hexadecimal
color constant.number "-?0[xX][0-9a-fA-F][0-9a-fA-F_]*"
## Real
### Decimal
color constant.number "-?\d[\d_]*.\d[\d_]*([eE][+-]\d[\d_]*.\d[\d_]*)?"
### Hexadecimal
color constant.number "-?0[xX][0-9a-fA-F][0-9a-fA-F_]*.[0-9a-fA-F][0-9a-fA-F_]*([pP][+-][0-9a-fA-F][0-9a-fA-F_]*.[0-9a-fA-F][0-9a-fA-F_]*)?"
# Comments
color comment start="\(\*" end="\*\)"

View File

@@ -2,12 +2,6 @@ syntax "pascal" "\.pas$"
# color identifier "\b[\pL_][\pL_\pN]*\b"
color comment "//.*"
color comment start="\(\*" end="\*\)"
color comment start="({)(?:[^$])" end="}"
color special start="asm" end="end"
color type "\b(?i:(string|ansistring|widestring|shortstring|char|ansichar|widechar|boolean|byte|shortint|word|smallint|longword|cardinal|longint|integer|int64|single|currency|double|extended))\b"
color statement "\b(?i:(and|asm|array|begin|break|case|const|constructor|continue|destructor|div|do|downto|else|end|file|for|function|goto|if|implementation|in|inline|interface|label|mod|not|object|of|on|operator|or|packed|procedure|program|record|repeat|resourcestring|set|shl|shr|then|to|type|unit|until|uses|var|while|with|xor))\b"
@@ -15,10 +9,15 @@ color statement "\b(?i:(as|class|dispose|except|exit|exports|finalization|finall
color statement "\b(?i:(absolute|abstract|alias|assembler|cdecl|cppdecl|default|export|external|forward|generic|index|local|name|nostackframe|oldfpccall|override|pascal|private|protected|public|published|read|register|reintroduce|safecall|softfloat|specialize|stdcall|virtual|write))\b"
color constant "\b(?i:(false|true|nil))\b"
color constant "\$[0-9A-Fa-f]+" "\b[+-]?[0-9]+([.]?[0-9]+)?(?i:e[+-]?[0-9]+)?"
color special start="asm" end="end"
color constant.number "\$[0-9A-Fa-f]+" "\b[+-]?[0-9]+([.]?[0-9]+)?(?i:e[+-]?[0-9]+)?"
color constant.string "#[0-9]{1,}"
color constant.string "'(?:[^']+|'')*'"
color preproc start="{\$" end="}"
color preproc start="{\$" end="}"
color comment "//.*"
color comment start="\(\*" end="\*\)"
color comment start="({)(?:[^$])" end="}"

View File

@@ -24,7 +24,9 @@ color statement "(=>|===|!==|==|!=|&&|\|\||::|=|->|\!)"
color default "(\$[a-zA-Z0-9\-_]+)"
color default "[\(|\)|/|+|-|\*|\[|,|;]"
color constant.string "('.*?'|\".*?\")"
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
color constant.specialChar "\\[abfnrtv'\"\\]"
color comment "(^|[[:space:]])//.*"
color comment "(^|[[:space:]])#.*"
color comment start="/\*" end="\*/"
color comment "(#.*|//.*)$"

View File

@@ -11,21 +11,21 @@ color statement "\b(if|then|elseif|else|end|match|where|try|with|as|recover|obje
color statement "\b(while|do|repeat|until|for|in)\b"
color statement "(\?|=>)"
color statement "(\\||\\&|\\,|\\^)"
color statement "(\||\&|\,|\^)"
color statement "(\-|\+|\\*|/|\!|%|<<|>>)"
color statement "(\-|\+|\*|/|\!|%|<<|>>)"
color statement "(==|!=|<=|>=|<|>)"
color statement "\b(is|isnt|not|and|or|xor)\b"
color type "\b(_*[A-Z][_a-zA-Z0-9\\']*)\b"
color type "\b(_*[A-Z][_a-zA-Z0-9\']*)\b"
color constant "\b(this)\b"
color constant "\b(true|false)\b"
color constant.number "\b((0b[0-1_]*)|(0o[0-7_]*)|(0x[0-9a-fA-F_]*)|([0-9_]+(\\.[0-9_]+)?((e|E)(\\+|-)?[0-9_]+)?))\b"
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
color constant.number "\b((0b[0-1_]*)|(0o[0-7_]*)|(0x[0-9a-fA-F_]*)|([0-9_]+(\.[0-9_]+)?((e|E)(\\+|-)?[0-9_]+)?))\b"
color constant.string ""(\\.|[^"])*""
color comment start=""""([^"]|$)" end="""""
color comment start=""""[^"]*" end="""""
color comment "(^|[[:space:]])//.*"
color comment start="/\*" end="\*/"
color todo "TODO:?"

View File

@@ -16,7 +16,7 @@ color identifier "\b(__abs__|__add__|__and__|__call__|__cmp__|__coerce__|__compl
## exception classes
# color cyan "\b(Exception|StandardError|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|EOFError|FloatingPointError|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|RuntimeError|SyntaxError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|ValueError|WindowsError|ZeroDivisionError)\b"
## types
color type "\b(basestring|bool|buffer|bytearray|bytes|classmethod|complex|dict|enumerate|file|float|frozenset|int|list|long|map|memoryview|object|property|reversed|set|slice|staticmethod|str|super|tuple|type|unicode|xrange)"
color type "\b(basestring|bool|buffer|bytearray|bytes|classmethod|complex|dict|enumerate|file|float|frozenset|int|list|long|map|memoryview|object|property|reversed|set|slice|staticmethod|str|super|tuple|type|unicode|xrange)\b"
#color type "\b(NoneType|TypeType|IntType|LongType|FloatType|ComplexType|StringType|UnicodeType|BufferType|TupleType|ListType|DictType|FunctionType|LambdaType|CodeType|ClassType|UnboundMethodType|InstanceType|MethodType|BuiltinFunctionType|BuiltinMethodType|ModuleType|FileType|XRangeType|TracebackType|FrameType|SliceType|EllipsisType)\b"
## definitions
color identifier "def [a-zA-Z_0-9]+"

View File

@@ -1,6 +1,6 @@
## Here is an example for Python.
##
syntax "python3" "\.py$"
syntax "python3" "\.py3$"
header "^#!.*/(env +)?python3$"
## built-in objects
@@ -16,7 +16,7 @@ color identifier "\b(__abs__|__add__|__and__|__call__|__cmp__|__coerce__|__compl
## exception classes
# color cyan "\b(Exception|StandardError|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|EOFError|FloatingPointError|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|RuntimeError|SyntaxError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|ValueError|WindowsError|ZeroDivisionError)\b"
## types
color type "\b(bool|bytearray|bytes|classmethod|complex|dict|enumerate|filter|float|frozenset|int|list|map|memoryview|object|property|range|reversed|set|slice|staticmethod|str|super|tuple|type|zip)"
color type "\b(bool|bytearray|bytes|classmethod|complex|dict|enumerate|filter|float|frozenset|int|list|map|memoryview|object|property|range|reversed|set|slice|staticmethod|str|super|tuple|type|zip)\b"
#color type "\b(NoneType|TypeType|IntType|LongType|FloatType|ComplexType|StringType|UnicodeType|BufferType|TupleType|ListType|DictType|FunctionType|LambdaType|CodeType|ClassType|UnboundMethodType|InstanceType|MethodType|BuiltinFunctionType|BuiltinMethodType|ModuleType|FileType|TracebackType|FrameType|SliceType|EllipsisType)\b"
## definitions
color identifier "def [a-zA-Z_0-9]+"

View File

@@ -0,0 +1,41 @@
# Solidity syntax for Micro
# Copyright (C) 2016 Nicolai Søborg
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
syntax "solidity" "\.sol$"
color preproc "\b(contract|library|pragma)\b"
color constant.number "\b[-]?([0-9]+|0x[0-9a-fA-F]+)\b"
color identifier "[a-zA-Z][_a-zA-Z0-9]*[[:space:]]*"
color statement "\b(assembly|break|continue|do|for|function|if|else|new|return|returns|while)\b"
color special "\b(\.send|throw)\b" # make sure they are very visible
color keyword "\b(anonymous|constant|indexed|payable|public|private|external|internal)\b"
color constant "\b(block(\.(blockhash|coinbase|difficulty|gaslimit|number|timestamp))?|msg(\.(data|gas|sender|value))?|now|tx(\.(gasprice|origin))?)\b"
color constant "\b(keccak256|sha3|sha256|ripemd160|ecrecover|addmod|mulmod|this|super|selfdestruct|\.balance)\b"
color constant "\b(true|false)\b"
color constant "\b(wei|szabo|finney|ether|seconds|minutes|hours|days|weeks|years)\b"
color type "\b(address|bool|mapping|string|var|int(\d*)|uint(\d*)|byte(\d*)|fixed(\d*)|ufixed(\d*))\b"
color error "\b(abstract|after|case|catch|default|final|in|inline|interface|let|match|null|of|pure|relocatable|static|switch|try|type|typeof|view)\b"
color operator "[-+/*=<>!~%?:&|]"
color comment "(^|[[:space:]])//.*"
color comment "/\*.+\*/"
color todo "TODO:?"
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"

21
runtime/syntax/toml.micro Normal file
View File

@@ -0,0 +1,21 @@
syntax "toml" "\.toml$"
# Keys
color statement "(.*)[[:space:]]="
color special "="
# Bracket thingies
color special "(\[|\])"
# Numbers and strings
color constant.number "\b([0-9]+|0x[0-9a-fA-F]*)\b|'.'"
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
color constant.specialChar "\\[abfnrtv'\"\\]"
color constant.specialChar "\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
color constant.string "`[^`]*`"
color constant.specialChar """
color constant.specialChar "'"
# Comments & TODOs
color comment "(^|[[:space:]])#.*"
color todo "(TODO|XXX|FIXME):?"

View File

@@ -15,10 +15,11 @@ cp README.md micro-$1
HASH="$(git rev-parse --short HEAD)"
VERSION="$(go run tools/build-version.go)"
DATE="$(go run tools/build-date.go)"
ADDITIONAL_GO_LINKER_FLAGS="$(go run tools/info-plist.go $VERSION)"
# Mac
echo "OSX 64"
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE'" -o micro-$1/micro ./cmd/micro
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE' $ADDITIONAL_GO_LINKER_FLAGS" -o micro-$1/micro ./cmd/micro
tar -czf micro-$1-osx.tar.gz micro-$1
mv micro-$1-osx.tar.gz binaries

45
tools/info-plist.go Normal file
View File

@@ -0,0 +1,45 @@
package main
import (
"os"
"fmt"
"runtime"
"io/ioutil"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
if runtime.GOOS == "darwin" {
if len(os.Args) == 2 {
raw_info_plist_string := `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>io.github.micro-editor</string>
<key>CFBundleName</key>
<string>micro</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>` + os.Args[1] + `</string>
</dict>
</plist>
`
info_plist_data := []byte(raw_info_plist_string)
err := ioutil.WriteFile("/tmp/micro-info.plist", info_plist_data, 0644)
check(err)
fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist")
} else {
panic("missing argument for version number!")
}
}
}