Skip to content

Commit 274e35d

Browse files
author
mroldao
committed
Merge branch 'master'
2 parents 1c1a7d9 + 9183fbe commit 274e35d

160 files changed

Lines changed: 2646 additions & 1314 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# See http://editorconfig.org
1+
# See https://editorconfig.org
22

33
# In Go files we indent with tabs but still
44
# set indent_size to control the GitHub web viewer.
55
[*.go]
66
indent_size=4
7-

.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.17.x, 1.23.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:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22

33
micro
4+
micro.exe
45
!cmd/micro
56
binaries/
67
tmp.sh

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

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<img alt="micro logo" src="./assets/micro-logo-drop.svg" width="500px"/>
22

33
![Test Workflow](https://github.com/zyedidia/micro/actions/workflows/test.yaml/badge.svg)
4-
[![Go Report Card](https://goreportcard.com/badge/github.com/zyedidia/micro)](https://goreportcard.com/report/github.com/zyedidia/micro)
4+
[![Go Report Card](https://goreportcard.com/badge/github.com/zyedidia/micro/v2)](https://goreportcard.com/report/github.com/zyedidia/micro/v2)
55
[![Release](https://img.shields.io/github/release/zyedidia/micro.svg?label=Release)](https://github.com/zyedidia/micro/releases)
66
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/zyedidia/micro/blob/master/LICENSE)
77
[![Join the chat at https://gitter.im/zyedidia/micro](https://badges.gitter.im/zyedidia/micro.svg)](https://gitter.im/zyedidia/micro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -47,7 +47,7 @@ You can also check out the website for Micro at https://micro-editor.github.io.
4747
- Syntax highlighting for over [130 languages](runtime/syntax).
4848
- Color scheme support.
4949
- By default, micro comes with 16, 256, and true color themes.
50-
- True color support (set the `MICRO_TRUECOLOR` environment variable to 1 to enable it).
50+
- True color support.
5151
- Copy and paste with the system clipboard.
5252
- Small and simple.
5353
- Easily configurable.
@@ -142,7 +142,7 @@ for other operating systems. These packages are not guaranteed to be up-to-date.
142142
* `winget install zyedidia.micro`
143143
* OpenBSD: Available in the ports tree and also available as a binary package.
144144
* `pkg_add -v micro`.
145-
* NetBSD, macOS, Linux, Illumos, etc. with [pkgsrc](http://www.pkgsrc.org/)-current:
145+
* NetBSD, macOS, Linux, Illumos, etc. with [pkgsrc](https://www.pkgsrc.org/)-current:
146146
* `pkg_add micro`
147147
* macOS: Available in package managers.
148148
* `sudo port install micro` (with [MacPorts](https://www.macports.org))
@@ -162,7 +162,7 @@ Without these tools installed, micro will use an internal clipboard for copy and
162162

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

165-
Make sure that you have Go version 1.17 or greater and Go modules are enabled.
165+
Make sure that you have Go version 1.19 or greater and Go modules are enabled.
166166

167167
```
168168
git clone https://github.com/zyedidia/micro
@@ -196,7 +196,7 @@ Native macOS builds are done with `CGO_ENABLED=1` forced set to support adding t
196196

197197
### macOS terminal
198198

199-
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.
199+
If you are using macOS, you should consider using [iTerm2](https://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.
200200

201201
If you still insist on using the default Mac terminal, be sure to set `Use Option key as Meta key` under
202202
`Preferences->Profiles->Keyboard` to use <kbd>option</kbd> as <kbd>alt</kbd>.

assets/packaging/micro.1

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,104 @@
1-
.TH micro 1 "2020-02-10"
1+
.TH micro 1 "2025-09-03"
22
.SH NAME
33
micro \- A modern and intuitive terminal-based text editor
44
.SH SYNOPSIS
55
.B micro
6-
.RB [OPTIONS]
7-
[FILE]\&...
8-
6+
.RI [ OPTION ]...\&
7+
.RI [ FILE ]...\&
8+
.RI [+ LINE [: COL ]]\&
9+
.RI [+/ REGEX ]
10+
.br
11+
.B micro
12+
.RI [ OPTION ]...\&
13+
.RI [ FILE [: LINE [: COL ]]]...\&
14+
\& (only if the `parsecursor` option is enabled)
915
.SH DESCRIPTION
10-
1116
Micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the full capabilities
1217
of modern terminals. It comes as one single, batteries-included, static binary with no dependencies.
1318

1419
As the name indicates, micro aims to be somewhat of a successor to the nano editor by being easy to install and use in a pinch, but micro also aims to be
1520
enjoyable to use full time, whether you work in the terminal because you prefer it (like me), or because you need to (over ssh).
1621

1722
Use Ctrl-q to quit, Ctrl-s to save, and Ctrl-g to open the in-editor help menu.
18-
1923
.SH OPTIONS
2024
.PP
21-
\-clean
25+
.B \-clean
2226
.RS 4
23-
Cleans the configuration directory
27+
Clean the configuration directory and exit
2428
.RE
25-
2629
.PP
27-
\-config-dir dir
30+
.B \-config-dir
31+
.I dir
2832
.RS 4
2933
Specify a custom location for the configuration directory
3034
.RE
31-
3235
.PP
33-
[FILE]:LINE:COL
36+
.IR FILE : LINE [: COL ]
37+
(only if the `parsecursor` option is enabled)
38+
.br
39+
.IR FILE \ + LINE [: COL ]
3440
.RS 4
3541
Specify a line and column to start the cursor at when opening a buffer
3642
.RE
37-
3843
.PP
39-
\-options
44+
.RI +/ REGEX
4045
.RS 4
41-
Show all option help
46+
Specify a regex to search for when opening a buffer
4247
.RE
43-
4448
.PP
45-
\-debug
49+
.B \-options
50+
.RS 4
51+
Show all options help and exit
52+
.RE
53+
.PP
54+
.B \-debug
4655
.RS 4
4756
Enable debug mode (enables logging to ./log.txt)
4857
.RE
49-
5058
.PP
51-
\-version
59+
.B \-profile
5260
.RS 4
53-
Show the version number and information
61+
Enable CPU profiling (writes profile info to ./micro.prof so it can be analyzed later with "go tool pprof micro.prof")
62+
.RE
63+
.PP
64+
.B \-version
65+
.RS 4
66+
Show the version number and information and exit
5467
.RE
5568

5669
Micro's plugins can be managed at the command line with the following commands.
5770
.RS 4
58-
5971
.PP
60-
\-plugin remove [PLUGIN]...
72+
.B \-plugin install
73+
.RI [ PLUGIN ]...
74+
.RS 4
75+
Install plugin(s)
76+
.RE
77+
.PP
78+
.B \-plugin remove
79+
.RI [ PLUGIN ]...
6180
.RS 4
6281
Remove plugin(s)
6382
.RE
64-
6583
.PP
66-
\-plugin update [PLUGIN]...
84+
.B \-plugin update
85+
.RI [ PLUGIN ]...
6786
.RS 4
6887
Update plugin(s) (if no argument is given, updates all plugins)
6988
.RE
70-
7189
.PP
72-
\-plugin search [PLUGIN]...
90+
.B \-plugin search
91+
.RI [ PLUGIN ]...
7392
.RS 4
7493
Search for a plugin
7594
.RE
76-
7795
.PP
78-
\-plugin list
96+
.B \-plugin list
7997
.RS 4
8098
List installed plugins
8199
.RE
82-
83100
.PP
84-
\-plugin available
101+
.B \-plugin available
85102
.RS 4
86103
List available plugins
87104
.RE
@@ -91,35 +108,33 @@ Micro's options can also be set via command line arguments for quick
91108
adjustments. For real configuration, please use the settings.json
92109
file (see 'help options').
93110
.RS 4
94-
95111
.PP
96-
\-option value
112+
.BI \-< option >
113+
.I value
97114
.RS 4
98-
Set `option` to `value` for this session
115+
Set `option` to `value` for this session.
116+
.br
99117
For example: `micro -syntax off file.c`
100118
.RE
101-
102-
119+
.RE
120+
.PP
121+
Use `micro -options` to see the full list of configuration options.
103122
.SH CONFIGURATION
104-
105123
Micro uses $MICRO_CONFIG_HOME as the configuration directory.
106124
If this environment variable is not set, it uses $XDG_CONFIG_HOME/micro instead.
107125
If that environment variable is not set, it uses ~/.config/micro as the configuration directory.
108126
In the documentation, we use ~/.config/micro to refer to the configuration directory
109127
(even if it may in fact be somewhere else if you have set either of the above environment variables).
110-
111128
.SH NOTICE
112129
This manpage is intended only to serve as a quick guide to the invocation of
113130
micro and is not intended to replace the full documentation included with micro
114131
which can be accessed from within micro. Micro tells you what key combination to
115132
press to get help in the lower right.
116-
117133
.SH BUGS
118134
A comprehensive list of bugs will not be listed in this manpage. See the Github
119135
page at \fBhttps://github.com/zyedidia/micro/issues\fP for a list of known bugs
120136
and to report any newly encountered bugs you may find. We strive to correct
121137
bugs as swiftly as possible.
122-
123138
.SH COPYRIGHT
124139
Copyright \(co 2020 Zachary Yedidia, et al. MIT license.
125140
See \fBhttps://github.com/zyedidia/micro\fP for details.

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)