Skip to content

Commit 40f3997

Browse files
Merge branch 'master' into MultiCursorAutoComplete
2 parents be32cf3 + 98ff79d commit 40f3997

File tree

161 files changed

+2169
-1350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+2169
-1350
lines changed

.github/workflows/nightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
nightly:
88
strategy:
99
matrix:
10-
go-version: [1.19.x]
10+
go-version: [1.23.x]
1111
os: [ubuntu-latest]
1212
runs-on: ${{ matrix.os }}
1313
steps:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
release:
99
strategy:
1010
matrix:
11-
go-version: [1.19.x]
11+
go-version: [1.23.x]
1212
os: [ubuntu-latest]
1313
runs-on: ${{ matrix.os }}
1414
steps:

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
test:
55
strategy:
66
matrix:
7-
go-version: [1.19.x]
7+
go-version: [1.19.x, 1.23.x]
88
os: [ubuntu-latest, macos-latest, windows-latest]
99
runs-on: ${{ matrix.os }}
1010
steps:

LICENSE-THIRD-PARTY

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
430430

431431
github.com/gdamore/tcell/LICENSE
432432
================
433-
github.com/zyedidia/tcell/LICENSE (fork)
433+
github.com/micro-editor/tcell/LICENSE (fork)
434434
================
435435

436436

@@ -1048,7 +1048,7 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
10481048

10491049
github.com/flynn/json5/LICENSE
10501050
================
1051-
github.com/zyedidia/json5/LICENSE (fork)
1051+
github.com/micro-editor/json5/LICENSE (fork)
10521052
================
10531053

10541054
Decoder code based on package encoding/json from the Go language.
@@ -1108,7 +1108,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11081108

11091109
github.com/james4k/terminal/LICENSE
11101110
================
1111-
github.com/zyedidia/terminal/LICENSE (fork)
1111+
github.com/micro-editor/terminal/LICENSE (fork)
11121112
================
11131113

11141114
Copyright (C) 2013 James Gray

Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,31 @@ VERSION = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH
55
HASH = $(shell git rev-parse --short HEAD)
66
DATE = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
77
go run tools/build-date.go)
8-
ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) \
9-
GOARCH=$(shell go env GOHOSTARCH) \
10-
go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)")
118
GOBIN ?= $(shell go env GOPATH)/bin
129
GOVARS = -X github.com/zyedidia/micro/v2/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/v2/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(DATE)'
1310
DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON
1411
VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/'
12+
CGO_ENABLED := $(if $(CGO_ENABLED),$(CGO_ENABLED),0)
13+
14+
ADDITIONAL_GO_LINKER_FLAGS := ""
15+
GOHOSTOS = $(shell go env GOHOSTOS)
16+
ifeq ($(GOHOSTOS), darwin)
17+
# Native darwin resp. macOS builds need external and dynamic linking
18+
ADDITIONAL_GO_LINKER_FLAGS += $(shell GOOS=$(GOHOSTOS) \
19+
GOARCH=$(shell go env GOHOSTARCH) \
20+
go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)")
21+
CGO_ENABLED = 1
22+
endif
1523

1624
build: generate build-quick
1725

1826
build-quick:
19-
go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
27+
CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
2028

2129
build-dbg:
22-
go build -trimpath -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro
30+
CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "$(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro
2331

24-
build-tags: fetch-tags generate
25-
go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
32+
build-tags: fetch-tags build
2633

2734
build-all: build
2835

@@ -32,7 +39,7 @@ install: generate
3239
install-all: install
3340

3441
fetch-tags:
35-
git fetch --tags
42+
git fetch --tags --force
3643

3744
generate:
3845
GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) go generate ./runtime

README.md

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,8 @@ Here is a picture of micro editing its source code.
1818
![Screenshot](./assets/micro-solarized.png)
1919

2020
To see more screenshots of micro, showcasing some of the default color schemes, see [here](https://micro-editor.github.io).
21-
22-
You can also check out the website for Micro at https://micro-editor.github.io.
2321

24-
## Table of Contents
25-
26-
- [Features](#features)
27-
- [Installation](#installation)
28-
- [Prebuilt binaries](#pre-built-binaries)
29-
- [Package Managers](#package-managers)
30-
- [Building from source](#building-from-source)
31-
- [Fully static binary](#fully-static-binary)
32-
- [macOS terminal](#macos-terminal)
33-
- [Linux clipboard support](#linux-clipboard-support)
34-
- [Colors and syntax highlighting](#colors-and-syntax-highlighting)
35-
- [Cygwin, Mingw, Plan9](#cygwin-mingw-plan9)
36-
- [Usage](#usage)
37-
- [Documentation and Help](#documentation-and-help)
38-
- [Contributing](#contributing)
22+
You can also check out the website for Micro at https://micro-editor.github.io.
3923

4024
- - -
4125

@@ -88,7 +72,7 @@ Pre-built binaries are distributed in [releases](https://github.com/zyedidia/mic
8872

8973
To uninstall micro, simply remove the binary, and the configuration directory at `~/.config/micro`.
9074

91-
#### Quick-install script
75+
#### Third-party quick-install script
9276

9377
```bash
9478
curl https://getmic.ro | bash
@@ -178,7 +162,7 @@ Without these tools installed, micro will use an internal clipboard for copy and
178162

179163
If your operating system does not have a binary release, but does run Go, you can build from source.
180164

181-
Make sure that you have Go version 1.16 or greater and Go modules are enabled.
165+
Make sure that you have Go version 1.19 or greater and Go modules are enabled.
182166

183167
```
184168
git clone https://github.com/zyedidia/micro
@@ -196,16 +180,20 @@ You can install directly with `go get` (`go get github.com/zyedidia/micro/cmd/mi
196180
recommended because it doesn't build micro with version information (necessary for the plugin manager),
197181
and doesn't disable debug mode.
198182

199-
### Fully static binary
183+
### Fully static or dynamically linked binary
200184

201-
By default, the micro binary will dynamically link with core system libraries (this is generally
202-
recommended for security and portability). However, there is a fully static prebuilt binary that
203-
is provided for amd64 as `linux-static.tar.gz`, and to build a fully static binary from source, run
185+
By default, the micro binary is linked statically to increase the portability of the prebuilt binaries.
186+
This behavior can simply be overriden by providing `CGO_ENABLED=1` to the build target.
204187

205188
```
206-
CGO_ENABLED=0 make build
189+
CGO_ENABLED=1 make build
207190
```
208191

192+
Afterwards the micro binary will dynamically link with the present core system libraries.
193+
194+
**Note for Mac:**
195+
Native macOS builds are done with `CGO_ENABLED=1` forced set to support adding the "Information Property List" in the linker step.
196+
209197
### macOS terminal
210198

211199
If you are using macOS, you should consider using [iTerm2](http://iterm2.com/) instead of the default terminal (Terminal.app). The iTerm2 terminal has much better mouse support as well as better handling of key events. For best keybinding behavior, choose `xterm defaults` under `Preferences->Profiles->Keys->Presets...`, and select `Esc+` for `Left Option Key` in the same menu. The newest versions also support true color.

cmd/micro/clean.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ package main
33
import (
44
"bufio"
55
"encoding/gob"
6+
"errors"
67
"fmt"
7-
"io/ioutil"
88
"os"
99
"path/filepath"
1010
"sort"
1111
"strings"
1212

1313
"github.com/zyedidia/micro/v2/internal/buffer"
1414
"github.com/zyedidia/micro/v2/internal/config"
15+
"github.com/zyedidia/micro/v2/internal/util"
1516
)
1617

1718
func shouldContinue() bool {
@@ -39,7 +40,16 @@ func CleanConfig() {
3940
}
4041

4142
fmt.Println("Cleaning default settings")
42-
config.WriteSettings(filepath.Join(config.ConfigDir, "settings.json"))
43+
44+
settingsFile := filepath.Join(config.ConfigDir, "settings.json")
45+
err := config.WriteSettings(settingsFile)
46+
if err != nil {
47+
if errors.Is(err, util.ErrOverwrite) {
48+
fmt.Println(err.Error())
49+
} else {
50+
fmt.Println("Error writing settings.json file: " + err.Error())
51+
}
52+
}
4353

4454
// detect unused options
4555
var unusedOptions []string
@@ -67,16 +77,20 @@ func CleanConfig() {
6777
fmt.Printf("%s (value: %v)\n", s, config.GlobalSettings[s])
6878
}
6979

70-
fmt.Printf("These options will be removed from %s\n", filepath.Join(config.ConfigDir, "settings.json"))
80+
fmt.Printf("These options will be removed from %s\n", settingsFile)
7181

7282
if shouldContinue() {
7383
for _, s := range unusedOptions {
7484
delete(config.GlobalSettings, s)
7585
}
7686

77-
err := config.OverwriteSettings(filepath.Join(config.ConfigDir, "settings.json"))
87+
err := config.OverwriteSettings(settingsFile)
7888
if err != nil {
79-
fmt.Println("Error writing settings.json file: " + err.Error())
89+
if errors.Is(err, util.ErrOverwrite) {
90+
fmt.Println(err.Error())
91+
} else {
92+
fmt.Println("Error overwriting settings.json file: " + err.Error())
93+
}
8094
}
8195

8296
fmt.Println("Removed unused options")
@@ -85,12 +99,13 @@ func CleanConfig() {
8599
}
86100

87101
// detect incorrectly formatted buffer/ files
88-
files, err := ioutil.ReadDir(filepath.Join(config.ConfigDir, "buffers"))
102+
buffersPath := filepath.Join(config.ConfigDir, "buffers")
103+
files, err := os.ReadDir(buffersPath)
89104
if err == nil {
90105
var badFiles []string
91106
var buffer buffer.SerializedBuffer
92107
for _, f := range files {
93-
fname := filepath.Join(config.ConfigDir, "buffers", f.Name())
108+
fname := filepath.Join(buffersPath, f.Name())
94109
file, e := os.Open(fname)
95110

96111
if e == nil {
@@ -105,9 +120,9 @@ func CleanConfig() {
105120
}
106121

107122
if len(badFiles) > 0 {
108-
fmt.Printf("Detected %d files with an invalid format in %s\n", len(badFiles), filepath.Join(config.ConfigDir, "buffers"))
123+
fmt.Printf("Detected %d files with an invalid format in %s\n", len(badFiles), buffersPath)
109124
fmt.Println("These files store cursor and undo history.")
110-
fmt.Printf("Removing badly formatted files in %s\n", filepath.Join(config.ConfigDir, "buffers"))
125+
fmt.Printf("Removing badly formatted files in %s\n", buffersPath)
111126

112127
if shouldContinue() {
113128
removed := 0

cmd/micro/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func (NullWriter) Write(data []byte) (n int, err error) {
1818
// InitLog sets up the debug log system for micro if it has been enabled by compile-time variables
1919
func InitLog() {
2020
if util.Debug == "ON" {
21-
f, err := os.OpenFile("log.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
21+
f, err := os.OpenFile("log.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, util.FileMode)
2222
if err != nil {
2323
log.Fatalf("error opening file: %v", err)
2424
}

0 commit comments

Comments
 (0)