mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-31 07:07:09 +09:00
Compare commits
29 Commits
tcell2.0.7
...
v2.0.10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b97638566e | ||
|
|
7a1ba01621 | ||
|
|
2b8cd6b758 | ||
|
|
cbe339da07 | ||
|
|
e290ce2de5 | ||
|
|
c7fd4ba5f1 | ||
|
|
0efc919f24 | ||
|
|
c315a91fc6 | ||
|
|
6e1fe5b301 | ||
|
|
84a490f14c | ||
|
|
42a9302636 | ||
|
|
ae0c28a03d | ||
|
|
1a5518ebbb | ||
|
|
160a81c572 | ||
|
|
4a2a72983f | ||
|
|
33e064b3b9 | ||
|
|
005442a4d0 | ||
|
|
6c666190e2 | ||
|
|
9ceb69921a | ||
|
|
4b0db74770 | ||
|
|
3bfd367d87 | ||
|
|
6d5beb50ba | ||
|
|
3d0b5db2e4 | ||
|
|
ee9c78dc86 | ||
|
|
b66ec2bf7a | ||
|
|
2dc2cabe0e | ||
|
|
56c7744e23 | ||
|
|
9bc32d4be9 | ||
|
|
0b0c99f1f5 |
@@ -274,12 +274,6 @@ func main() {
|
||||
fmt.Println("Fatal: Micro could not initialize a Screen.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
sigterm = make(chan os.Signal, 1)
|
||||
sighup = make(chan os.Signal, 1)
|
||||
signal.Notify(sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
|
||||
signal.Notify(sighup, syscall.SIGHUP)
|
||||
|
||||
m := clipboard.SetMethod(config.GetGlobalOption("clipboard").(string))
|
||||
clipErr := clipboard.Initialize(m)
|
||||
|
||||
@@ -319,6 +313,8 @@ func main() {
|
||||
screen.TermMessage(err)
|
||||
}
|
||||
|
||||
action.InitGlobals()
|
||||
buffer.SetMessager(action.InfoBar)
|
||||
args := flag.Args()
|
||||
b := LoadInput(args)
|
||||
|
||||
@@ -329,7 +325,6 @@ func main() {
|
||||
}
|
||||
|
||||
action.InitTabs(b)
|
||||
action.InitGlobals()
|
||||
|
||||
err = config.RunPluginFn("init")
|
||||
if err != nil {
|
||||
@@ -352,6 +347,11 @@ func main() {
|
||||
|
||||
screen.Events = make(chan tcell.Event)
|
||||
|
||||
sigterm = make(chan os.Signal, 1)
|
||||
sighup = make(chan os.Signal, 1)
|
||||
signal.Notify(sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
|
||||
signal.Notify(sighup, syscall.SIGHUP)
|
||||
|
||||
// Here is the event loop which runs in a separate thread
|
||||
go func() {
|
||||
for {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component>
|
||||
<id>com.github.zyedidia.micro</id>
|
||||
<launchable type="desktop-id">micro.desktop</launchable>
|
||||
<name>Micro Text Editor</name>
|
||||
<summary>A modern and intuitive terminal-based text editor</summary>
|
||||
<metadata_license>MIT</metadata_license>
|
||||
|
||||
4
go.mod
4
go.mod
@@ -16,8 +16,8 @@ require (
|
||||
github.com/zyedidia/glob v0.0.0-20170209203856-dd4023a66dc3
|
||||
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/v2 v2.0.7
|
||||
github.com/zyedidia/pty v1.1.15 // indirect
|
||||
github.com/zyedidia/tcell/v2 v2.0.8
|
||||
github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415
|
||||
golang.org/x/text v0.3.2
|
||||
gopkg.in/sourcemap.v1 v1.0.5 // indirect
|
||||
|
||||
13
go.sum
13
go.sum
@@ -23,8 +23,6 @@ github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGe
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/p-e-w/go-runewidth v0.0.10-0.20200613030200-3e1705c5c059 h1:/+h2b6i15wh4EWsFkfdNdBE1jjGA872tpXEyhPM5aYg=
|
||||
github.com/p-e-w/go-runewidth v0.0.10-0.20200613030200-3e1705c5c059/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||
@@ -33,7 +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/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=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
@@ -56,12 +53,10 @@ github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d h1:zmDMkh22zXOB7gz8
|
||||
github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d/go.mod h1:NDJSTTYWivnza6zkRapeX2/LwhKPEMQ7bJxqgDVT78I=
|
||||
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/v2 v2.0.6 h1:v0GoNpPYJ+Wbd1RiSL09SUFzoq4eVKTuT5awbW6aqGs=
|
||||
github.com/zyedidia/tcell/v2 v2.0.6/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
|
||||
github.com/zyedidia/tcell/v2 v2.0.7 h1:kFzCRq9jgx5lOXBT8fVZidbTgVuX0ws++aMCj/MTCYY=
|
||||
github.com/zyedidia/tcell/v2 v2.0.7/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
|
||||
github.com/zyedidia/pty v1.1.15 h1:XlxMFph7HDvTn4sDG8Klgmb/g4ATGiSj4655vAETp1U=
|
||||
github.com/zyedidia/pty v1.1.15/go.mod h1:HWbpfrLoVM9FmU+/9NV+PzVQV8jSxgnQLk8fvx0q/i8=
|
||||
github.com/zyedidia/tcell/v2 v2.0.8 h1:/WYLXyVJwSc6xQG1ZDXGpzTenzhWtRtsz4G5XsFKQQ4=
|
||||
github.com/zyedidia/tcell/v2 v2.0.8/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
|
||||
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=
|
||||
|
||||
@@ -903,7 +903,7 @@ func (h *BufPane) find(useRegex bool) bool {
|
||||
h.Relocate()
|
||||
}
|
||||
}
|
||||
InfoBar.Prompt(prompt, "", "Find", eventCallback, func(resp string, canceled bool) {
|
||||
findCallback := func(resp string, canceled bool) {
|
||||
// Finished callback
|
||||
if !canceled {
|
||||
match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex)
|
||||
@@ -926,8 +926,15 @@ func (h *BufPane) find(useRegex bool) bool {
|
||||
h.Cursor.ResetSelection()
|
||||
}
|
||||
h.Relocate()
|
||||
})
|
||||
|
||||
}
|
||||
pattern := string(h.Cursor.GetSelection())
|
||||
if eventCallback != nil && pattern != "" {
|
||||
eventCallback(pattern)
|
||||
}
|
||||
InfoBar.Prompt(prompt, pattern, "Find", eventCallback, findCallback)
|
||||
if pattern != "" {
|
||||
InfoBar.SelectAll()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ var bufdefaults = map[string]string{
|
||||
"Ctrl-o": "OpenFile",
|
||||
"Ctrl-s": "Save",
|
||||
"Ctrl-f": "Find",
|
||||
"Alt-F": "FindLiteral",
|
||||
"Ctrl-n": "FindNext",
|
||||
"Ctrl-p": "FindPrevious",
|
||||
"Ctrl-z": "Undo",
|
||||
|
||||
@@ -40,6 +40,7 @@ var bufdefaults = map[string]string{
|
||||
"Ctrl-o": "OpenFile",
|
||||
"Ctrl-s": "Save",
|
||||
"Ctrl-f": "Find",
|
||||
"Alt-F": "FindLiteral",
|
||||
"Ctrl-n": "FindNext",
|
||||
"Ctrl-p": "FindPrevious",
|
||||
"Ctrl-z": "Undo",
|
||||
|
||||
@@ -26,8 +26,9 @@ The backup was created on %s, and the file is
|
||||
When the buffer is closed, the backup will be removed.
|
||||
* 'ignore' will ignore the backup, discarding its changes. The backup file
|
||||
will be removed.
|
||||
* 'abort' will abort the open operation, and instead open an empty buffer.
|
||||
|
||||
Options: [r]ecover, [i]gnore: `
|
||||
Options: [r]ecover, [i]gnore, [a]bort: `
|
||||
|
||||
var backupRequestChan chan *Buffer
|
||||
|
||||
@@ -118,7 +119,7 @@ func (b *Buffer) RemoveBackup() {
|
||||
|
||||
// ApplyBackup applies the corresponding backup file to this buffer (if one exists)
|
||||
// Returns true if a backup was applied
|
||||
func (b *Buffer) ApplyBackup(fsize int64) bool {
|
||||
func (b *Buffer) ApplyBackup(fsize int64) (bool, bool) {
|
||||
if b.Settings["backup"].(bool) && !b.Settings["permbackup"].(bool) && len(b.Path) > 0 && b.Type == BTDefault {
|
||||
backupfile := filepath.Join(config.ConfigDir, "backups", util.EscapePath(b.AbsPath))
|
||||
if info, err := os.Stat(backupfile); err == nil {
|
||||
@@ -127,20 +128,22 @@ func (b *Buffer) ApplyBackup(fsize int64) bool {
|
||||
defer backup.Close()
|
||||
t := info.ModTime()
|
||||
msg := fmt.Sprintf(backupMsg, t.Format("Mon Jan _2 at 15:04, 2006"), util.EscapePath(b.AbsPath))
|
||||
choice := screen.TermPrompt(msg, []string{"r", "i", "recover", "ignore"}, true)
|
||||
choice := screen.TermPrompt(msg, []string{"r", "i", "a", "recover", "ignore", "abort"}, true)
|
||||
|
||||
if choice%2 == 0 {
|
||||
if choice%3 == 0 {
|
||||
// recover
|
||||
b.LineArray = NewLineArray(uint64(fsize), FFAuto, backup)
|
||||
b.isModified = true
|
||||
return true
|
||||
} else if choice%2 == 1 {
|
||||
return true, true
|
||||
} else if choice%3 == 1 {
|
||||
// delete
|
||||
os.Remove(backupfile)
|
||||
} else if choice%3 == 2 {
|
||||
return false, false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return false, true
|
||||
}
|
||||
|
||||
@@ -250,10 +250,14 @@ func NewBufferFromFileAtLoc(path string, btype BufType, cursorLoc Loc) (*Buffer,
|
||||
return nil, err
|
||||
} else {
|
||||
buf = NewBuffer(file, util.FSize(file), filename, cursorLoc, btype)
|
||||
if buf == nil {
|
||||
return nil, errors.New("could not open file")
|
||||
}
|
||||
}
|
||||
|
||||
if readonly {
|
||||
buf.SetOptionNative("readonly", true)
|
||||
if readonly && prompt != nil {
|
||||
prompt.Message("Warning: file is readonly - sudo will be attempted when saving")
|
||||
// buf.SetOptionNative("readonly", true)
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
@@ -332,8 +336,12 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
|
||||
b.Settings["encoding"] = "utf-8"
|
||||
}
|
||||
|
||||
hasBackup = b.ApplyBackup(size)
|
||||
var ok bool
|
||||
hasBackup, ok = b.ApplyBackup(size)
|
||||
|
||||
if !ok {
|
||||
return NewBufferFromString("", "", btype)
|
||||
}
|
||||
if !hasBackup {
|
||||
reader := bufio.NewReader(transform.NewReader(r, enc.NewDecoder()))
|
||||
|
||||
|
||||
@@ -82,3 +82,13 @@ func (b *Buffer) ClearMessages(owner string) {
|
||||
func (b *Buffer) ClearAllMessages() {
|
||||
b.Messages = make([]*Message, 0)
|
||||
}
|
||||
|
||||
type Messager interface {
|
||||
Message(msg ...interface{})
|
||||
}
|
||||
|
||||
var prompt Messager
|
||||
|
||||
func SetMessager(m Messager) {
|
||||
prompt = m
|
||||
}
|
||||
|
||||
@@ -91,9 +91,10 @@ func (b *Buffer) findUp(r *regexp.Regexp, start, end Loc) ([2]Loc, bool) {
|
||||
l = util.SliceStart(l, end.X)
|
||||
}
|
||||
|
||||
match := r.FindIndex(l)
|
||||
all_matches := r.FindAllIndex(l, -1)
|
||||
|
||||
if match != nil {
|
||||
if all_matches != nil {
|
||||
match := all_matches[len(all_matches)-1]
|
||||
start := Loc{charpos + util.RunePos(l, match[0]), i}
|
||||
end := Loc{charpos + util.RunePos(l, match[1]), i}
|
||||
return [2]Loc{start, end}, true
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -52,7 +52,7 @@ color support comes in three flavors.
|
||||
environment variable `MICRO_TRUECOLOR` to 1. In addition your terminal
|
||||
must support it (usually indicated by setting `$COLORTERM` to `truecolor`).
|
||||
True-color colorschemes in micro typically end with `-tc`, such as
|
||||
`solarized-tc`, `atom-dark-tc`, `material-tc`, etc... If true color is not
|
||||
`solarized-tc`, `atom-dark`, `material-tc`, etc... If true color is not
|
||||
enabled but a true color colorscheme is used, micro will do its best to
|
||||
approximate the colors to the available 256 colors.
|
||||
|
||||
@@ -69,7 +69,7 @@ themes the most.
|
||||
* `darcula`
|
||||
* `twilight`
|
||||
* `railscast`
|
||||
* `bubblegum`
|
||||
* `bubblegum` (light theme)
|
||||
|
||||
### 16 color
|
||||
|
||||
@@ -91,11 +91,10 @@ variable `MICRO_TRUECOLOR` must be set to 1. Note that you have to create
|
||||
and set this variable yourself.
|
||||
|
||||
* `solarized-tc`: this is the solarized colorscheme for true color.
|
||||
* `atom-dark-tc`: this colorscheme is based off of Atom's "dark" colorscheme.
|
||||
* `atom-dark`: this colorscheme is based off of Atom's "dark" colorscheme.
|
||||
* `cmc-tc`: A true colour variant of the cmc theme. It requires true color to
|
||||
look its best. Use cmc-16 if your terminal doesn't support true color.
|
||||
* `gruvbox-tc`: The true color version of the gruvbox colorscheme
|
||||
* `github-tc`: The true color version of the Github colorscheme
|
||||
* `material-tc`: Colorscheme based off of Google's Material Design palette
|
||||
|
||||
## Creating a Colorscheme
|
||||
|
||||
@@ -31,6 +31,10 @@ Here is a list of terminal emulators and their status:
|
||||
|
||||
* `gnome-terminal`: does not support OSC 52.
|
||||
|
||||
* `alacritty`: supported.
|
||||
|
||||
* `foot`: supported.
|
||||
|
||||
**Summary:** If you want copy and paste to work over SSH, then you
|
||||
should set `clipboard` to `terminal`, and make sure your terminal
|
||||
supports OSC 52.
|
||||
|
||||
@@ -53,7 +53,7 @@ following in `bindings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"Ctrl-r": "redo"
|
||||
"Ctrl-r": "Redo"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -83,9 +83,11 @@ function preinit()
|
||||
makeLinter("pylint", "python", "pylint", {"--output-format=parseable", "--reports=no", "%f"}, "%f:%l: %m")
|
||||
makeLinter("flake8", "python", "flake8", {"%f"}, "%f:%l:%c: %m")
|
||||
makeLinter("shfmt", "shell", "shfmt", {"%f"}, "%f:%l:%c: %m")
|
||||
makeLinter("shellcheck", "shell", "shellcheck", {"-f", "gcc", "%f"}, "%f:%l:%c:.+: %m")
|
||||
makeLinter("swiftc", "swift", "xcrun", {"swiftc", "%f"}, "%f:%l:%c:.+: %m", {"darwin"}, true)
|
||||
makeLinter("swiftc", "swift", "swiftc", {"%f"}, "%f:%l:%c:.+: %m", {"linux"}, true)
|
||||
makeLinter("swiftc-linux", "swift", "swiftc", {"%f"}, "%f:%l:%c:.+: %m", {"linux"}, true)
|
||||
makeLinter("yaml", "yaml", "yamllint", {"--format", "parsable", "%f"}, "%f:%l:%c:.+ %m")
|
||||
makeLinter("nix-linter", "nix", "nix-linter", {"%f"}, "%m at %f:%l:%c", {"linux"}, true)
|
||||
|
||||
config.MakeCommand("lint", function(bp, args)
|
||||
bp:Save()
|
||||
@@ -123,12 +125,11 @@ function runLinter(buf)
|
||||
ftmatch = false
|
||||
end
|
||||
|
||||
local args = {}
|
||||
for k, arg in pairs(v.args) do
|
||||
args[k] = arg:gsub("%%f", file):gsub("%%d", dir)
|
||||
end
|
||||
|
||||
if ftmatch then
|
||||
local args = {}
|
||||
for k, arg in pairs(v.args) do
|
||||
args[k] = arg:gsub("%%f", file):gsub("%%d", dir)
|
||||
end
|
||||
lint(buf, k, v.cmd, args, v.errorformat, v.loffset, v.coffset, v.callback)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,6 +7,7 @@ rules:
|
||||
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
|
||||
- type: "\\b(auto|float|double|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\\b"
|
||||
- type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b"
|
||||
- type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b"
|
||||
- type.extended: "\\b(bool)\\b"
|
||||
- statement: "\\b(volatile|register)\\b"
|
||||
- statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
|
||||
|
||||
@@ -7,6 +7,7 @@ rules:
|
||||
- identifier: "\\b[A-Z_][0-9A-Z_]*\\b"
|
||||
- type: "\\b(float|double|bool|char|int|short|long|enum|void|struct|union|typedef|(un)?signed|inline)\\b"
|
||||
- type: "\\b(((s?size)|((u_?)?int(8|16|32|64|ptr))|char(8|16|32))_t|wchar_t)\\b"
|
||||
- type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b"
|
||||
- type: "\\b(final|override)\\b"
|
||||
- type.keyword: "\\b(auto|volatile|const(expr|eval|init)?|mutable|register|thread_local|static|extern|decltype|explicit|virtual)\\b"
|
||||
- statement: "\\b(class|namespace|template|typename|this|friend|using|public|protected|private|noexcept)\\b"
|
||||
|
||||
@@ -38,4 +38,8 @@ rules:
|
||||
start: "\\(\\*"
|
||||
end: "\\*\\)"
|
||||
rules:
|
||||
- todo: "(TODO|FIXME|WONTFIX|NOTE|HACK):?"
|
||||
- todo: "(TODO|FIXME|WONTFIX|NOTE|HACK):?"
|
||||
- comment:
|
||||
start: "%"
|
||||
end: "$"
|
||||
rules: []
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
filetype: lisp
|
||||
|
||||
detect:
|
||||
filename: "(emacs|zile)$|\\.(el|li?sp|scm|ss)$"
|
||||
filename: "(emacs|zile)$|\\.(el|li?sp|scm|ss|rkt)$"
|
||||
|
||||
rules:
|
||||
- default: "\\([a-z-]+"
|
||||
|
||||
@@ -18,7 +18,7 @@ rules:
|
||||
- constant.number: "\\b0[bB][01][01_]+\\b"
|
||||
- constant.number: "\\b[0-9_]((\\.?)[0-9_]+)?[eE][+\\-][0-9][0-9_]+\\b"
|
||||
- constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'"
|
||||
- comment: "[[:space:]]*#.*$"
|
||||
- comment: "[[:space:]]*[^\\\\]#.*$"
|
||||
- comment:
|
||||
start: "\\#\\["
|
||||
end: "\\]\\#"
|
||||
|
||||
27
runtime/syntax/nix.yaml
Normal file
27
runtime/syntax/nix.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
filetype: nix
|
||||
|
||||
detect:
|
||||
filename: "\\.nix$"
|
||||
|
||||
rules:
|
||||
- special: "\\b(Ellipsis|null|self|super|true|false|abort)\\b"
|
||||
- statement: "\\b(let|in|with|import|rec|inherit)\\b"
|
||||
- symbol.operator: "([~^.:;,+*|=!\\%@]|<|>|/|-|&)"
|
||||
- symbol.brackets: "([(){}]|\\[|\\])"
|
||||
|
||||
- constant.number: "\\b[0-9](_?[0-9])*(\\.([0-9](_?[0-9])*)?)?(e[0-9](_?[0-9])*)?\\b"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
rules: []
|
||||
|
||||
- constant.string:
|
||||
start: "''"
|
||||
end: "''"
|
||||
rules: []
|
||||
|
||||
- comment:
|
||||
start: "#"
|
||||
end: "$"
|
||||
rules: []
|
||||
@@ -24,15 +24,27 @@ rules:
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
skip: '\\.'
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
- constant.specialChar: '\\.'
|
||||
|
||||
- constant.string:
|
||||
start: "r#+\""
|
||||
end: "\"#+"
|
||||
rules: []
|
||||
|
||||
# Character literals
|
||||
# NOTE: This is an ugly hack to work around the fact that rust uses
|
||||
# single quotes both for character literals and lifetimes.
|
||||
# Match all character literals.
|
||||
- constant.string: "'(\\\\.|.)'"
|
||||
# Match the '"' literal which would otherwise match
|
||||
# as a double quoted string and destroy the highlighting.
|
||||
- constant.string:
|
||||
start: "'\""
|
||||
end: "'"
|
||||
rules: []
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
@@ -49,4 +61,3 @@ rules:
|
||||
start: "#!\\["
|
||||
end: "\\]"
|
||||
rules: []
|
||||
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
filetype: shell
|
||||
|
||||
# Detection based on filename is rather complicated as there are many
|
||||
# different file extensions and special filenames in use.
|
||||
# This expressions aims to capture them all while not matching
|
||||
# filenames that coincidentally contain the same substring.
|
||||
#
|
||||
# File extensions:
|
||||
# * .sh
|
||||
# * .bash
|
||||
# * .ash
|
||||
# * .ebuild (Gentoo ebuild format)
|
||||
#
|
||||
# Special filenames:
|
||||
# * .bashrc, .bash_aliases, .bash_functions .bash_profile
|
||||
# * profile, .profile (/etc/profile or ~/.profile)
|
||||
# * Pkgfile
|
||||
# * pkgmk.conf
|
||||
# * rc.conf
|
||||
# * PKGBUILD (Arch Linux build scripts)
|
||||
# * APKBUILD
|
||||
#
|
||||
# Fix command (fc) files:
|
||||
# * bash-fc. (followed by a random string)
|
||||
detect:
|
||||
filename: "(\\.sh$|\\.bash|\\.ash|bashrc|bash_aliases|bash_functions|profile|bash-fc\\.|Pkgfile|pkgmk.conf|rc.conf|PKGBUILD|.ebuild\\$|APKBUILD)"
|
||||
filename: '(\.(sh|bash|ash|ebuild)$|(\.bash(rc|_aliases|_functions|_profile)|\.?profile|Pkgfile|pkgmk\.conf|rc\.conf|PKGBUILD|APKBUILD)$|bash-fc\.)'
|
||||
header: "^#!.*/(env +)?(ba)?(a)?(mk)?sh( |$)"
|
||||
|
||||
rules:
|
||||
|
||||
@@ -3,34 +3,35 @@ filetype: v
|
||||
detect:
|
||||
|
||||
rules:
|
||||
# Conditionals and control flow
|
||||
- keywords: "\\b(import|go|defer)\\b"
|
||||
- special: "\\b(or|break|continue|match|case|goto|return|none)\\b"
|
||||
- function: "\\b(fn)\\b"
|
||||
- main_function: "\\b(fn main\\(\\))"
|
||||
- optionals: "\\b(none|error\\()"
|
||||
- statement: "\\b(if|else|for|match)\\b"
|
||||
- assert: "\\b(assert)\\b"
|
||||
- symbol.operator: "\\b([-+/*=<>!~%&|^])\\b"
|
||||
- symbol.operator: "\\b(:=)\\b"
|
||||
- symbol.operator: "\\b(\\|\\|)\b"
|
||||
- symbol.operator: "\\b(\\&\\&)\\b"
|
||||
# Conditionals and control flow
|
||||
- preproc: "\\b(module|import)\\b"
|
||||
- statement: "\\b(if|else|for|match|select|defer|or|unsafe)\\b"
|
||||
- statement: "\\b(break|continue|goto|return)\\b"
|
||||
- type.keyword: "\\b(assert|const|enum|fn|struct|interface|type)\\b"
|
||||
- type.keyword: "\\b(pub|mut|__global)\\b"
|
||||
|
||||
- compile_if: "\\b(\\$if|\\$else)\\b"
|
||||
- oses: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|js|android|solaris|haiku)\\b"
|
||||
- preproc: "\\$\\b(if|else)\\b"
|
||||
- identifier.os: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|android|solaris|haiku)\\b"
|
||||
- identifier.compiler: "\\b(gcc|tinyc|clang|mingw|msvc|cplusplus)\\b"
|
||||
- identifier.platform: "\\b(amd64|aarch64|x64|x32|little_endian|big_endian)\\b"
|
||||
- identifier.other: "\\b(debug|test|js|glibc|prealloc|no_bounds_checking)\\b"
|
||||
|
||||
- identifier.class: "\\b([A-Z][A-Za-z0-9_]*)\\b"
|
||||
- identifier.function: "\\b([a-z_]+\\()"
|
||||
- symbol.operator: "\\b(i[ns])\\b|[-+/*<>!=~*%&:|,.?]"
|
||||
- symbol.attribute:
|
||||
start: "^\\["
|
||||
end: "\\]$"
|
||||
rules:
|
||||
- default: ".*"
|
||||
- symbol: "\\b(deprecated|direct_array_access|if|inline|live|ref_only|typedef|windows_stdcall)\\b"
|
||||
|
||||
# Types
|
||||
- symbol: "(,|\\.)"
|
||||
- btype: "\\b(bool)\\b"
|
||||
- ztype: "\\b(char|byte)\\b"
|
||||
- itype: "\\b(int|i(8|16|64)|u(8|16|32|64))\\b"
|
||||
- ftype: "\\b(f(32|64))\\b"
|
||||
- ptype: "\\b(uintptr|charptr|byteptr|voidptr)\\b"
|
||||
- atype: "\\b(array)\\b"
|
||||
- stype: "\\b(string|ustring)\\b"
|
||||
- mtype: "\\b(map)\\b"
|
||||
- type.keyword: "\\b(pub|mut|struct|enum|interface|module|type|const)\\b"
|
||||
- type: "\\b(byte|u(16|32|64|128)|i(nt|8|16|64|128)|f(32|64))\\b"
|
||||
- type: "\\b(bool|cha[nr]|map|rune|string)\\b"
|
||||
- type: "\\b(any(_int|_float)?|size_t|(uint|byte|char|void)ptr)\\b"
|
||||
- constant.bool: "\\b(true|false)\\b"
|
||||
- constant.none: "\\b(none)\\b"
|
||||
|
||||
# Brackets
|
||||
- symbol.brackets: "(\\{|\\})"
|
||||
@@ -38,7 +39,10 @@ rules:
|
||||
- symbol.brackets: "(\\[|\\])"
|
||||
|
||||
# Numbers and strings
|
||||
- constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'"
|
||||
- constant.number: "\\b(0b[01_]+)\\b"
|
||||
- constant.number: "\\b(0o[0-7_]+)\\b"
|
||||
- constant.number: "\\b(0x[0-9a-fA-F_]+)\\b"
|
||||
- constant.number: "\\b([0-9_]+)\\b"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
@@ -46,7 +50,7 @@ rules:
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- constant.specialChar: "%."
|
||||
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
|
||||
- constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]"
|
||||
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
|
||||
|
||||
- constant.string:
|
||||
@@ -54,9 +58,8 @@ rules:
|
||||
end: "'"
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- error: "..+"
|
||||
- constant.specialChar: "%."
|
||||
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
|
||||
- constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]"
|
||||
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
|
||||
|
||||
- constant.string:
|
||||
@@ -75,10 +78,3 @@ rules:
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- function.attribute:
|
||||
start: "^\\["
|
||||
end: "\\]$"
|
||||
rules:
|
||||
- known: "\\b(deprecated|inline|typedef|if)\\b"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user