diff --git a/internal/action/actions.go b/internal/action/actions.go index 733321d1..925c97e8 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -614,8 +614,6 @@ func (h *BufPane) Autocomplete() bool { // InsertTab inserts a tab or spaces func (h *BufPane) InsertTab() bool { b := h.Buf - l := b.LineBytes(h.Cursor.Y) - l = util.SliceStart(l, h.Cursor.X) indent := b.IndentString(util.IntOpt(b.Settings["tabsize"])) tabBytes := len(indent) bytesUntilIndent := tabBytes - (h.Cursor.GetVisualX() % tabBytes) @@ -810,7 +808,11 @@ func (h *BufPane) Copy() bool { if h.Cursor.HasSelection() { h.Cursor.CopySelection("clipboard") h.freshClip = true - InfoBar.Message("Copied selection") + if clipboard.Unsupported { + InfoBar.Message("Copied selection (install xclip for external clipboard)") + } else { + InfoBar.Message("Copied selection") + } } h.Relocate() return true @@ -984,7 +986,11 @@ func (h *BufPane) paste(clip string) { h.Buf.Insert(h.Cursor.Loc, clip) // h.Cursor.Loc = h.Cursor.Loc.Move(Count(clip), h.Buf) h.freshClip = false - InfoBar.Message("Pasted clipboard") + if clipboard.Unsupported { + InfoBar.Message("Pasted clipboard (install xclip for external clipboard)") + } else { + InfoBar.Message("Pasted clipboard") + } } // JumpToMatchingBrace moves the cursor to the matching brace if it is diff --git a/internal/action/command.go b/internal/action/command.go index 2656e1da..31fc9f9c 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -35,37 +35,37 @@ var commands map[string]Command func InitCommands() { commands = map[string]Command{ - "set": Command{(*BufPane).SetCmd, OptionValueComplete}, - "reset": Command{(*BufPane).ResetCmd, OptionValueComplete}, - "setlocal": Command{(*BufPane).SetLocalCmd, OptionValueComplete}, - "show": Command{(*BufPane).ShowCmd, OptionComplete}, - "showkey": Command{(*BufPane).ShowKeyCmd, nil}, - "run": Command{(*BufPane).RunCmd, nil}, - "bind": Command{(*BufPane).BindCmd, nil}, - "unbind": Command{(*BufPane).UnbindCmd, nil}, - "quit": Command{(*BufPane).QuitCmd, nil}, - "goto": Command{(*BufPane).GotoCmd, nil}, - "save": Command{(*BufPane).SaveCmd, nil}, - "replace": Command{(*BufPane).ReplaceCmd, nil}, - "replaceall": Command{(*BufPane).ReplaceAllCmd, nil}, - "vsplit": Command{(*BufPane).VSplitCmd, buffer.FileComplete}, - "hsplit": Command{(*BufPane).HSplitCmd, buffer.FileComplete}, - "tab": Command{(*BufPane).NewTabCmd, buffer.FileComplete}, - "help": Command{(*BufPane).HelpCmd, HelpComplete}, - "eval": Command{(*BufPane).EvalCmd, nil}, - "log": Command{(*BufPane).ToggleLogCmd, nil}, - "plugin": Command{(*BufPane).PluginCmd, PluginComplete}, - "reload": Command{(*BufPane).ReloadCmd, nil}, - "reopen": Command{(*BufPane).ReopenCmd, nil}, - "cd": Command{(*BufPane).CdCmd, buffer.FileComplete}, - "pwd": Command{(*BufPane).PwdCmd, nil}, - "open": Command{(*BufPane).OpenCmd, buffer.FileComplete}, - "tabswitch": Command{(*BufPane).TabSwitchCmd, nil}, - "term": Command{(*BufPane).TermCmd, nil}, - "memusage": Command{(*BufPane).MemUsageCmd, nil}, - "retab": Command{(*BufPane).RetabCmd, nil}, - "raw": Command{(*BufPane).RawCmd, nil}, - "textfilter": Command{(*BufPane).TextFilterCmd, nil}, + "set": {(*BufPane).SetCmd, OptionValueComplete}, + "reset": {(*BufPane).ResetCmd, OptionValueComplete}, + "setlocal": {(*BufPane).SetLocalCmd, OptionValueComplete}, + "show": {(*BufPane).ShowCmd, OptionComplete}, + "showkey": {(*BufPane).ShowKeyCmd, nil}, + "run": {(*BufPane).RunCmd, nil}, + "bind": {(*BufPane).BindCmd, nil}, + "unbind": {(*BufPane).UnbindCmd, nil}, + "quit": {(*BufPane).QuitCmd, nil}, + "goto": {(*BufPane).GotoCmd, nil}, + "save": {(*BufPane).SaveCmd, nil}, + "replace": {(*BufPane).ReplaceCmd, nil}, + "replaceall": {(*BufPane).ReplaceAllCmd, nil}, + "vsplit": {(*BufPane).VSplitCmd, buffer.FileComplete}, + "hsplit": {(*BufPane).HSplitCmd, buffer.FileComplete}, + "tab": {(*BufPane).NewTabCmd, buffer.FileComplete}, + "help": {(*BufPane).HelpCmd, HelpComplete}, + "eval": {(*BufPane).EvalCmd, nil}, + "log": {(*BufPane).ToggleLogCmd, nil}, + "plugin": {(*BufPane).PluginCmd, PluginComplete}, + "reload": {(*BufPane).ReloadCmd, nil}, + "reopen": {(*BufPane).ReopenCmd, nil}, + "cd": {(*BufPane).CdCmd, buffer.FileComplete}, + "pwd": {(*BufPane).PwdCmd, nil}, + "open": {(*BufPane).OpenCmd, buffer.FileComplete}, + "tabswitch": {(*BufPane).TabSwitchCmd, nil}, + "term": {(*BufPane).TermCmd, nil}, + "memusage": {(*BufPane).MemUsageCmd, nil}, + "retab": {(*BufPane).RetabCmd, nil}, + "raw": {(*BufPane).RawCmd, nil}, + "textfilter": {(*BufPane).TextFilterCmd, nil}, } } @@ -240,7 +240,7 @@ func (h *BufPane) RawCmd(args []string) { // TextFilterCmd filters the selection through the command. // Selection goes to the command input. -// On successfull run command output replaces the current selection. +// On successful run command output replaces the current selection. func (h *BufPane) TextFilterCmd(args []string) { if len(args) == 0 { InfoBar.Error("usage: textfilter arguments") @@ -691,7 +691,7 @@ func (h *BufPane) BindCmd(args []string) { // UnbindCmd binds a key to its default action func (h *BufPane) UnbindCmd(args []string) { if len(args) < 1 { - InfoBar.Error("Not enough arguements") + InfoBar.Error("Not enough arguments") return } diff --git a/internal/action/infopane.go b/internal/action/infopane.go index 33b40268..00dde633 100644 --- a/internal/action/infopane.go +++ b/internal/action/infopane.go @@ -147,7 +147,7 @@ var InfoNones = []string{ "SkipMultiCursor", } -// InfoOverrides is the list of actions which have been overriden +// InfoOverrides is the list of actions which have been overridden // by the infohandler var InfoOverrides = map[string]InfoKeyAction{ "CursorUp": (*InfoPane).CursorUp, diff --git a/internal/action/terminal_supported.go b/internal/action/terminal_supported.go index 50e0a75d..21a6de0e 100644 --- a/internal/action/terminal_supported.go +++ b/internal/action/terminal_supported.go @@ -18,9 +18,8 @@ func RunTermEmulator(h *BufPane, input string, wait bool, getOutput bool, callba t := new(shell.Terminal) t.Start(args, getOutput, wait, callback, userargs) - id := h.ID() h.AddTab() - id = MainTab().Panes[0].ID() + id := MainTab().Panes[0].ID() v := h.GetView() MainTab().Panes[0] = NewTermPane(v.X, v.Y, v.Width, v.Height, t, id) diff --git a/internal/buffer/search.go b/internal/buffer/search.go index 4382971d..0930ba2c 100644 --- a/internal/buffer/search.go +++ b/internal/buffer/search.go @@ -115,7 +115,7 @@ func (b *Buffer) FindNext(s string, start, end, from Loc, down bool, useRegex bo return [2]Loc{}, false, err } - found := false + var found bool var l [2]Loc if down { l, found = b.findDown(r, from, end) diff --git a/internal/display/bufwindow.go b/internal/display/bufwindow.go index 3b478e7c..39934166 100644 --- a/internal/display/bufwindow.go +++ b/internal/display/bufwindow.go @@ -45,12 +45,12 @@ func (w *BufWindow) SetBuffer(b *buffer.Buffer) { w.Buf = b } -func (v *View) GetView() *View { - return v +func (w *BufWindow) GetView() *View { + return w.View } -func (v *View) SetView(view *View) { - v = view +func (w *BufWindow) SetView(view *View) { + w.View = view } func (w *BufWindow) Resize(width, height int) { diff --git a/runtime/help/colors.md b/runtime/help/colors.md index 38ea1784..d89c7692 100644 --- a/runtime/help/colors.md +++ b/runtime/help/colors.md @@ -200,7 +200,7 @@ In the future, plugins may also be able to use color groups for styling. ## Syntax files -The syntax files is written in yaml-format and specify how to highlight +The syntax files are written in yaml-format and specify how to highlight languages. Micro's builtin syntax highlighting tries very hard to be sane, sensible and diff --git a/runtime/syntax/bat.yaml b/runtime/syntax/bat.yaml new file mode 100644 index 00000000..e6077a57 --- /dev/null +++ b/runtime/syntax/bat.yaml @@ -0,0 +1,58 @@ +filetype: batch + +detect: + filename: "(\\.bat$)" + # header: "" + +rules: + # Numbers + - constant.number: "\\b[0-9]+\\b" + # Brackets and symbols + - special: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)" + # Conditionals and control flow + # note (?i) means case insensitive match + - type: "\\b(?i)(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|then|until|while)\\b" + - type: "\\b(?i)(equ|neq|lss|leq|gtr|geq|on|off)\\b" + - type: "\\b(?i)(goto|for|in|do|call|exit|not|exist|errorlevel|defined)\\b" + - type: "\\b(?i)(prn|nul|lpt3|lpt2|lpt1|con|com4|com3|com2|com1|aux)\\b" + # keywords + - statement: "\\b(?i)(adprep|append|arp|assoc|at|atmadm|attrib|auditpol|autochk|autoconv|autofmt|bcdboot|bcdedit|bdehdcfg|bitsadmin|bootcfg|break|brea)\\b" + - statement: "\\b(?i)(cacls|cd|certreq|certutil|chcp|change|choice|cipher|chdir|chkdsk|chkntfs|chglogon|chgport|chgusr|clip|cls|clscluadmin|cluster|cmd|cmdkey|cmstp|color)\\b" + - statement: "\\b(?i)(comp|compact|convert|copy|cprofile|cscript|csvde|date|dcdiag|dcgpofix|dcpromo|defra|del|dfscmd|dfsdiag|dfsrmig|diantz|dir|dirquota|diskcomp|diskcopy|diskpart|diskperf|diskraid|diskshadow|dispdiag|doin|dnscmd|doskey|driverquery|dsacls|dsadd|dsamain|dsdbutil|dsget|dsmgmt|dsmod|dsmove|dsquery|dsrm)\\b" + - statement: "\\b(?i)(echo|edit|endlocal|erase|esentutl|eventcreate|eventquery|eventtriggers|evntcmd|expand|extract)\\b" + - statement: "\\b(?i)(fc|filescrn|find|findstr|finger|flattemp|fonde|forfiles|format|freedisk|fs|fsutil|ftp|ftype|fveupdate|getmac|gettype|gpfixup|gpresult|gpupdate|graftabl)\\b" + - statement: "\\b(?i)(hashgen|hep|help|helpctr|hostname|icacls|iisreset|inuse|ipconfig|ipxroute|irftp|ismserv|jetpack|keyb|klist|ksetup|ktmutil|ktpass|label|ldifd|ldp|lodctr|logman|logoff|lpq|lpr|macfile)\\b" + - statement: "\\b(?i)(makecab|manage-bde|mapadmin|md|mkdir|mklink|mmc|mode|more|mount|mountvol|move|mqbup|mqsvc|mqtgsvc|msdt|msg|msiexec|msinfo32|mstsc|nbtstat|net computer|net group)\\b" + - statement: "\\b(?i)(net localgroup|net print|net session|net share|net start|net stop|net use|net user|net view|net|netcfg|netdiag|netdom|netsh|netstat|nfsadmin|nfsshare|nfsstat|nlb)\\b" + - statement: "\\b(?i)(nlbmgr|nltest|nslookup|ntackup|ntcmdprompt|ntdsutil|ntfrsutl|openfiles|pagefileconfig|path|pathping|pause|pbadmin|pentnt|perfmon|ping|pnpunatten|pnputil|popd)\\b" + - statement: "\\b(?i)(powercfg|powershell|powershell_ise|print|prncnfg|prndrvr|prnjobs|prnmngr|prnport|prnqctl|prompt|pubprn|pushd|pushprinterconnections|pwlauncher|qappsrv|qprocess)\\b" + - statement: "\\b(?i)(query|quser|qwinsta|rasdial|rcp|rd|rdpsign|regentc|recover|redircmp|redirusr|reg|regini|regsvr32|relog|ren|rename|rendom|repadmin|repair-bde|replace|reset|restore)\\b" + - statement: "\\b(?i)(rxec|risetup|rmdir|robocopy|route|rpcinfo|rpcping|rsh|runas|rundll32|rwinsta|scp|sc|setlocal|session|schtasks|scwcmd|secedit|serverceipoptin|servrmanagercmd|serverweroptin|set|setspn)\\b" + - statement: "\\b(?i)(setx|sfc|shadow|shift|showmount|shutdown|sort|ssh|start|storrept|subst|sxstrace|ysocmgr|systeminfo|takeown|tapicfg|taskkill|tasklist|tcmsetup|telnet|tftp|time)\\b" + - statement: "\\b(?i)(timeout|title|tlntadmn|tpmvscmgr|tpmvscmgr|tacerpt|tracert|tree|tscon|tsdiscon|tsecimp|tskill|tsprof|type|typeperf|tzutil|uddiconfig|umount|unlodctr|ver|verify)\\b" + - statement: "\\b(?i)(verifier|verif|vol|vssadmin|w32tm|waitfor|wbadmin|wdsutil|wecutil|wevtutil|where|whoami|winnt|winnt32|winpop|winrm|winrs|winsat|wlbs|mic|wscript|xcopy)\\b" + # / Flags + - constant: "(/\\w+)" + # Variables + - special: "(%%\\w+)" + - special: "(%\\w+%)" + # Conditional flags + - type: "--[a-z-]+" + - type: "\\ -[a-z]+" + + - identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?" + - identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?" + # "" String + - constant.string: + start: \" + end: \" + skip: \. + rules: + - constant.specialChar: (\\0|\\\\|\\t|\\n|\\r|\\"|\\') + - constant.unicode: \\u\{[[:xdigit:]]+} + # '' string + - constant.string: "(\\'.+\\')" + # rem as comment + - comment.rem: "(?i)(rem\\s.*)" + # :: as comment + - comment.rem: "(?i)(\\:\\:\\s.*)" diff --git a/runtime/syntax/crystal.yaml b/runtime/syntax/crystal.yaml index de80e531..faf0c700 100644 --- a/runtime/syntax/crystal.yaml +++ b/runtime/syntax/crystal.yaml @@ -36,7 +36,11 @@ rules: skip: "\\\\." rules: - constant.specialChar: "\\\\." - - special: "#\\{[^}]*\\}" + - symbol.brackets: + start: "#\\{" + end: "\\}" + rules: + - default: ".*" - constant.string: start: "'" diff --git a/runtime/syntax/git-commit.yaml b/runtime/syntax/git-commit.yaml index 3429edd2..d8c16479 100644 --- a/runtime/syntax/git-commit.yaml +++ b/runtime/syntax/git-commit.yaml @@ -23,3 +23,14 @@ rules: start: "^#" end: "$" rules: [] + + # Diffs (i.e. git commit --verbose) + - default: + start: "^diff" + # Diff output puts a space before file contents on each line so this + # should never match valid diff output and extend highlighting to the + # end of the file + end: "^ENDOFFILE" + limit-group: "magenta" + rules: + - include: "patch" diff --git a/runtime/syntax/html.yaml b/runtime/syntax/html.yaml index d858096f..d17ec7f0 100644 --- a/runtime/syntax/html.yaml +++ b/runtime/syntax/html.yaml @@ -1,13 +1,13 @@ filetype: html -detect: +detect: filename: "\\.htm[l]?$" rules: - error: "<[^!].*?>" - symbol.tag: "(?i)<[/]?(a(bbr|cronym|ddress|pplet|rea|rticle|side|udio)?|b(ase(font)?|d(i|o)|ig|lockquote|r)?|ca(nvas|ption)|center|cite|co(de|l|lgroup)|d(ata(list)?|d|el|etails|fn|ialog|ir|l|t)|em(bed)?|fieldset|fig(caption|ure)|font|form|(i)?frame|frameset|h[1-6]|hr|i|img|in(put|s)|kbd|keygen|label|legend|li(nk)?|ma(in|p|rk)|menu(item)?|met(a|er)|nav|no(frames|script)|o(l|pt(group|ion)|utput)|p(aram|icture|re|rogress)?|q|r(p|t|uby)|s(trike)?|samp|se(ction|lect)|small|source|span|strong|su(b|p|mmary)|textarea|time|track|u(l)?|var|video|wbr)( .*|>)*?>" - symbol.tag.extended: "(?i)<[/]?(body|div|html|head(er)?|footer|title|table|t(body|d|h(ead)?|r|foot))( .*)*?>" - - special: "&[^;[[:space:]]]*;" + - special: "&(#[[:digit:]]{1,4}|#x[[:xdigit:]]{1,4}|[^[[:space:]]]+);" - symbol: "[:=]" - identifier: "(alt|bgcolor|height|href|id|label|longdesc|name|on(click|focus|load|mouseover)|size|span|src|target|type|value|width)=" - constant.number: "(?i)#[0-9A-F]{6,6}" @@ -18,9 +18,13 @@ rules: - symbol.tag: "<|>" - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" - - comment: "" - preproc: "" + - comment: + start: "" + rules: [] + - constant.string: start: "\"" end: "\"" @@ -41,4 +45,3 @@ rules: limit-group: symbol.tag rules: - include: "css" - diff --git a/runtime/syntax/javascript.yaml b/runtime/syntax/javascript.yaml index f0ec9b97..24c8736d 100644 --- a/runtime/syntax/javascript.yaml +++ b/runtime/syntax/javascript.yaml @@ -16,17 +16,20 @@ rules: - symbol.brackets: "(\\{|\\})" - symbol.brackets: "(\\(|\\))" - symbol.brackets: "(\\[|\\])" - - symbol.operator: "[-+/*=<>!~%?:&|]" - - statement: "\\b(async|await|break|case|catch|const|continue|debugger|default|delete|do|else|export|finally)\\b" - - statement: "\\b(for|function|class|extends|get|if|import|from|in|of|instanceof|let|new|return|set)\\b" - - statement: "\\b(super|switch|this|throw|try|typeof|var|void|while|with|yield)\\b" + - symbol.operator: "([-+/*=<>!~%?:&|]|[.]{3})" + - statement: "\\b(async|await|break|case|catch|const|continue|debugger|default)\\b" + - statement: "\\b(delete|do|else|export|finally|for|function\\*?|class|extends)\\b" + - statement: "\\b(get|if|import|from|in|of|instanceof|let|new|reject|resolve|return)\\b" + - statement: "\\b(set|super|switch|this|throw|try|typeof|var|void|while|with|yield)\\b" # reserved but unassigned - error: "\\b(enum|implements|interface|package|private|protected|public|TODO)" - constant: "\\b(globalThis|Infinity|null|undefined|NaN)\\b" - constant: "\\b(null|undefined|NaN)\\b" - constant: "\\b(true|false)\\b" - - type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Math|Map|Set|WeakMap|WeakSet)\\b" - - type: "\\b(Number|Object|RegExp|String)\\b" + - type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Generator|Map|Math)\\b" + - type: "\\b(Number|Object|Promise|Proxy|Reflect|RegExp|Set|String|Symbol|WeakMap|WeakSet)\\b" + - type: "\\b(BigInt64Array|BigUint64Array|Float32Array|Float64Array|Int16Array)\\b" + # - constant: "/[^*]([^/]|(\\\\/))*[^\\\\]/[gim]*" - constant: "\\\\[0-7][0-7]?[0-7]?|\\\\x[0-9a-fA-F]+|\\\\[bfnrt'\"\\?\\\\]" - comment: "^#!.*/(env +)?node( |$)" @@ -55,6 +58,7 @@ rules: end: "`" rules: - constant.specialChar: "\\\\." + - identifier: "\\x24\\{.*?\\}" - comment: start: "//" diff --git a/runtime/syntax/julia.yaml b/runtime/syntax/julia.yaml index 73cbd5bf..ecda7c81 100644 --- a/runtime/syntax/julia.yaml +++ b/runtime/syntax/julia.yaml @@ -13,11 +13,11 @@ rules: # definitions - identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]" # keywords - - statement: "\\b(begin|break|catch|continue|function|elseif|struct|else|end|finally|for|global|local|const|if|include|import|using|require|macro|println|return|try|type|while|module)\\b" + - statement: "\\b(begin|break|catch|continue|function|elseif|struct|else|end|finally|for|global|local|let|const|if|import|using|macro|println|return|try|while|module)\\b" # decorators - identifier.macro: "@[A-Za-z0-9_]+" # operators - - symbol.operator: "[-+*/|=%<>&~^]|\\b(and|not|or|is|in)\\b" + - symbol.operator: "[-+*/|=%<>&~^]|\\b(isa|in)\\b" # parentheses - symbol.brackets: "([(){}]|\\[|\\])" # numbers diff --git a/runtime/syntax/kotlin.yaml b/runtime/syntax/kotlin.yaml index 6bcca0d5..cf3a6da1 100644 --- a/runtime/syntax/kotlin.yaml +++ b/runtime/syntax/kotlin.yaml @@ -1,7 +1,7 @@ filetype: kotlin detect: - filename: "\\.kt$" + filename: "\\.kts?$" rules: @@ -9,7 +9,7 @@ rules: - symbol.operator: ([.:;,+*|=!?\\%]|<|>|/|-|&) # Statements Keywords - - statement: \b(as|by|class|constructor|companion|fun|import|in|infix|interface|inline|is|out|operator|package|return|suspend|super|this|when|val|var)\b + - statement: \b(as|by|class|constructor|companion|const|fun|import|in|infix|interface|inline|is|out|operator|package|return|suspend|super|this|when|val|var)\b - statement.properties: \b(get|set)\b - statement.control: \b(break|continue|else|do|if|try|catch|finally|for|while)\b - statement.class: \b(abstract|annotation|data|enum|final|open|sealed)\b @@ -18,7 +18,7 @@ rules: - statement.parameter: \b(crossinline|noinline|reified|vararg)\b # Expression and types - - type: \b(dynamic|object|throw|typealias|typeof)\b + - type: \b(dynamic|object|throw|typealias)\b # Meta - statement.meta: \@(\bfile|delegate|field|get|property|receiver|set|setparam|param|)\b @@ -28,7 +28,7 @@ rules: - constant.number: ([0-9]+) # Storage Types - - type.storage: \b(Byte|Char|Double|Float|Int|Long|Short|Boolean|Unit|Nothing)\b + - type.storage: \b(Byte|UByte|Char|Double|Float|Int|UInt|Long|ULong|Short|UShort|Boolean|Unit|Nothing)\b # Collections - type.collections: \b(Array)\b @@ -63,4 +63,4 @@ rules: - todo: "(TODO|XXX|FIXME):?" # Todo - - todo: "(TODO|XXX|FIXME):?" \ No newline at end of file + - todo: "(TODO|XXX|FIXME):?" diff --git a/runtime/syntax/nim.yaml b/runtime/syntax/nim.yaml index 94b37ce4..2478774f 100644 --- a/runtime/syntax/nim.yaml +++ b/runtime/syntax/nim.yaml @@ -1,7 +1,7 @@ filetype: nim detect: - filename: "\\.nim$|\\.nims$|nim.cfg" + filename: "\\.nims?$|nim.cfg" rules: - 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[\\}\\|]" diff --git a/runtime/syntax/ruby.yaml b/runtime/syntax/ruby.yaml index b0b1816e..593fad52 100644 --- a/runtime/syntax/ruby.yaml +++ b/runtime/syntax/ruby.yaml @@ -1,26 +1,68 @@ filetype: ruby detect: - filename: "\\.rb$|\\.gemspec$|Gemfile|config.ru|Rakefile|Capfile|Vagrantfile" + filename: "\\.(rb|rake|gemspec)$|^(Gemfile|config.ru|Rakefile|Capfile|Vagrantfile|Guardfile)$" header: "^#!.*/(env +)?ruby( |$)" rules: - - statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\\b" + - comment.bright: + start: "##" + end: "$" + rules: + - todo: "(XXX|TODO|FIXME|BUG|\\?\\?\\?)" + - comment: + start: "#" + end: "$" + rules: + - todo: "(XXX|TODO|FIXME|BUG|\\?\\?\\?)" + + - statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|for|if|in|module|next|nil|not|or|private|protected|public|redo|rescue|retry|return|self|super|then|undef|unless|until|when|while|yield)\\b" - constant: "(\\$|@|@@)?\\b[A-Z]+[0-9A-Z_a-z]*" - - constant.number: "\\b[0-9]+\\b" + - constant.number: "(?i)\\b0x[0-9a-f][0-9a-f_]*\\b" + - constant.number: "(?i)\\b0b[01][01_]*\\b" + - constant.number: "(?i)\\b[0-9][0-9_]*(['.'][0-9_]+)?(e[\\-]?[0-9_]+)?\\b" + # Ruby "Symbols" - constant: "(i?)([ ]|^):[0-9A-Z_]+\\b" - constant: "\\b(__FILE__|__LINE__)\\b" - constant: "/([^/]|(\\\\/))*/[iomx]*|%r\\{([^}]|(\\\\}))*\\}[iomx]*" - - constant.string: "`[^`]*`|%x\\{[^}]*\\}" - - constant.string: "\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!" - - special: "#\\{[^}]*\\}" - - constant.string: "'([^']|(\\\\'))*'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!" - - comment: "#[^{].*$|#$" - - comment.bright: "##[^{].*$|##$" + + - constant.string: + start: "'" + end: "'" + skip: "\\\\." + rules: [] + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - symbol.brackets: + start: "#\\{" + end: "\\}" + rules: + - default: ".*" + + - constant.string.exec: + start: "`" + end: "`" + skip: "\\\\." + rules: + - symbol.brackets: + start: "#\\{" + end: "\\}" + rules: + - default: ".*" + + - constant.string: "%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!" + - constant.string: "%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!" + - constant.string.exec: "%[x]\\{[^}]*\\}|%[x]\\([^)]*\\)|%[x]<[^>]*>|%[x]\\[[^]]*\\]|%[x]\\$[^$]*\\$|%[x]\\^[^^]*\\^|%[x]![^!]*!" + - constant.bool: "\\b(true|false|nil|TRUE|FALSE|NIL)\\b" + - symbol.operator: "[-+/*=<>!~%&|^]|\\b:" + - symbol.brackets: "([(){}]|\\[|\\])" - constant.macro: start: "<<-?'?EOT'?" end: "^EOT" rules: [] - - todo: "(XXX|TODO|FIXME|\\?\\?\\?)" - preproc.shebang: "^#!.+?( |$)" diff --git a/runtime/syntax/svelte.yaml b/runtime/syntax/svelte.yaml new file mode 100644 index 00000000..2059e982 --- /dev/null +++ b/runtime/syntax/svelte.yaml @@ -0,0 +1,27 @@ +filetype: svelte + +detect: + filename: "\\.svelte$" + +rules: + - default: + start: "" + rules: + - include: "javascript" + + - default: + start: "" + rules: + - include: "typescript" + - default: + start: "" + end: "" + rules: + - include: "css" + - default: + start: "^" + end: "$" + rules: + - include: "html5" \ No newline at end of file diff --git a/runtime/syntax/v.yaml b/runtime/syntax/v.yaml new file mode 100644 index 00000000..6f1c96dd --- /dev/null +++ b/runtime/syntax/v.yaml @@ -0,0 +1,85 @@ +filetype: v + +detect: + filename: "\\.v$" + +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" + + - compile_if: "\\b(\\$if|\\$else)\\b" + - oses: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|js|android|solaris|haiku)\\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" + - constant.bool: "\\b(true|false)\\b" + + # Brackets + - symbol.brackets: "(\\{|\\})" + - symbol.brackets: "(\\(|\\))" + - symbol.brackets: "(\\[|\\])" + + # Numbers and strings + - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'" + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "%." + - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]" + - 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: + start: "'" + end: "'" + skip: "\\\\." + rules: + - error: "..+" + - constant.specialChar: "%." + - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]" + - 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: + start: "`" + end: "`" + rules: [] + + - comment: + start: "//" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - comment: + start: "/\\*" + end: "\\*/" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - function.attribute: + start: "^\\[" + end: "\\]$" + rules: + - known: "\\b(deprecated|inline|typedef|if)\\b" + diff --git a/runtime/syntax/verilog.yaml b/runtime/syntax/verilog.yaml new file mode 100644 index 00000000..97c41847 --- /dev/null +++ b/runtime/syntax/verilog.yaml @@ -0,0 +1,60 @@ +filetype: verilog + +detect: + filename: "\\.(vh|sv|svh)$" + +rules: + - preproc: "\\b(module|package|program|endmodule|endpackage|endprogram)\\b" + - type.keyword: "\\b(task|interface|class|endtask|endinterface|endclass)\\b" + # builtin functions like $display + - special: "\\$[0-9A-Za-z_]+" + + # Verilog keywords + - statement: "\\b(always|and|assign|automatic|begin|buf|bufif0|bufif1|case|casex|casez|cell|cmos|config)\\b" + - statement: "\\b(deassign|default|defparam|design|disable|edge|else|end|endcase|endconfig|endfunction|endgenerate)\\b" + - statement: "\\b(endprimitive|endspecify|endtable|event|for|force|forever|fork|function|generate)\\b" + - statement: "\\b(genvar|highz0|highz1|if|iff|ifnone|incdir|include|initial|input|instance|join)\\b" + - statement: "\\b(large|liblist|library|localparam|macromodule|medium|nand|negedge|nmos|nor|noshowcancelled)\\b" + - statement: "\\b(not|notif0|notif1|null|or|output|parameter|pmos|posedge|primitive|pull0|pull1|pulldown|pullup)\\b" + - statement: "\\b(pulsestyle_onevent|pulsestyle_ondetect|rcmos|realtime|reg|release|repeat|rnmos|rpmos|rtran)\\b" + - statement: "\\b(rtranif0|rtranif1|scalared|showcancelled|small|specify|specparam|strong0|strong1|supply0)\\b" + - statement: "\\b(supply1|table|time|tran|tranif0|tranif1|tri0|tri1|triand|trior|trireg|use|uwire)\\b" + - statement: "\\b(vectored|wait|wand|weak0|weak1|while|wor|xnor|xor)\\b" + + # SystemVerilog keywords + - statement: "\\b(alias|always_comb|always_ff|always_latch|assert|assume|before|bind|bins|binsof|break)\\b" + - statement: "\\b(chandle|clocking|const|constraint|context|continue|cover|covergroup|coverpoint|cross|dist|do)\\b" + - statement: "\\b(endclocking|endgroup|endproperty|endsequence|enum)\\b" + - statement: "\\b(expect|export|extends|extern|final|first_match|foreach|forkjoin|ignore_bins|illegal_bins|import)\\b" + - statement: "\\b(inside|intersect|join_any|join_none|local|longint|matches|modport|new)\\b" + - statement: "\\b(packed|priority|property|protected|pure|rand|randc|randcase|randsequence|ref|return)\\b" + - statement: "\\b(sequence|solve|static|struct|super|tagged|this|throughout|timeprecision)\\b" + - statement: "\\b(timeunit|type|typedef|union|unique|virtual|wait_order|wildcard|with|within)\\b" + + # types + - type.keyword: "\\b(int|integer|logic|wire|tri|unsigned|signed|inout|var|shortint|shortreal|real|void|string|bit|byte)\\b" + + # constants + - constant.number: "\\b[0-9]+\\b" + - constant.number: "\\b'[su]?[dboh][0-9xzXZa-fA-F]+\\b" + # .asdf(...) argument syntax + - special: "\\.((\\*)|([A-Za-z][A-Za-z0-9_]*))" + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - comment: + start: "/\\*" + end: "\\*/" + rules: + - todo: "(TODO|XXX|FIXME):?" diff --git a/runtime/syntax/vi.yaml b/runtime/syntax/vi.yaml index d7fe4962..d83a80af 100644 --- a/runtime/syntax/vi.yaml +++ b/runtime/syntax/vi.yaml @@ -24,7 +24,7 @@ rules: rules: - constant.specialChar: "\\\\." - - constant.comment: + - comment: start: "\"" end: "$" rules: [] diff --git a/runtime/syntax/vue.yaml b/runtime/syntax/vue.yaml index 4c1c3040..f6df706d 100644 --- a/runtime/syntax/vue.yaml +++ b/runtime/syntax/vue.yaml @@ -11,14 +11,20 @@ rules: - include: "html5" - default: - start: "" - end: "" + start: "" rules: - include: "javascript" + + - default: + start: "" + end: "" + rules: + - include: "typescript" - default: start: "" end: "" rules: - include: "css" - \ No newline at end of file + diff --git a/runtime/syntax/xml.yaml b/runtime/syntax/xml.yaml index dbc99512..d9b0111c 100644 --- a/runtime/syntax/xml.yaml +++ b/runtime/syntax/xml.yaml @@ -1,16 +1,32 @@ filetype: xml detect: - filename: "\\.(xml|sgml?|rng|plist)$" + filename: "\\.(xml|sgml?|rng|svg|plist)$" + header: "<\\?xml.*\\?>" rules: - - identifier: "<.*?>" - - comment: + - preproc: start: "" rules: [] - - comment: - start: "" - rules: [] - - special: "&[^;]*;" + - comment: "" + - symbol.tag: + start: "<\\??" + end: "\\??>" + rules: + - identifier: + start: " " + end: "=" + rules: [] + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + - constant.string: + start: "'" + end: "'" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." diff --git a/tools/cross-compile.sh b/tools/cross-compile.sh index ec4feac9..083a10ae 100755 --- a/tools/cross-compile.sh +++ b/tools/cross-compile.sh @@ -25,16 +25,25 @@ GOOS=linux GOARCH=amd64 make build mv micro micro-$1 tar -czf micro-$1-linux64.tar.gz micro-$1 mv micro-$1-linux64.tar.gz binaries + +echo "Linux 64 fully static" +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build +mv micro micro-$1 +tar -czf micro-$1-linux64-static.tar.gz micro-$1 +mv micro-$1-linux64-static.tar.gz binaries + echo "Linux 32" GOOS=linux GOARCH=386 make build mv micro micro-$1 tar -czf micro-$1-linux32.tar.gz micro-$1 mv micro-$1-linux32.tar.gz binaries + echo "Linux ARM 32" GOOS=linux GOARCH=arm make build mv micro micro-$1 tar -czf micro-$1-linux-arm.tar.gz micro-$1 mv micro-$1-linux-arm.tar.gz binaries + echo "Linux ARM 64" GOOS=linux GOARCH=arm64 make build mv micro micro-$1 @@ -47,6 +56,7 @@ GOOS=netbsd GOARCH=amd64 make build mv micro micro-$1 tar -czf micro-$1-netbsd64.tar.gz micro-$1 mv micro-$1-netbsd64.tar.gz binaries + echo "NetBSD 32" GOOS=netbsd GOARCH=386 make build mv micro micro-$1 @@ -59,6 +69,7 @@ GOOS=openbsd GOARCH=amd64 make build mv micro micro-$1 tar -czf micro-$1-openbsd64.tar.gz micro-$1 mv micro-$1-openbsd64.tar.gz binaries + echo "OpenBSD 32" GOOS=openbsd GOARCH=386 make build mv micro micro-$1 @@ -71,6 +82,7 @@ GOOS=freebsd GOARCH=amd64 make build mv micro micro-$1 tar -czf micro-$1-freebsd64.tar.gz micro-$1 mv micro-$1-freebsd64.tar.gz binaries + echo "FreeBSD 32" GOOS=freebsd GOARCH=386 make build mv micro micro-$1 @@ -85,6 +97,7 @@ GOOS=windows GOARCH=amd64 make build mv micro.exe micro-$1 zip -r -q -T micro-$1-win64.zip micro-$1 mv micro-$1-win64.zip binaries + echo "Windows 32" GOOS=windows GOARCH=386 make build mv micro.exe micro-$1 diff --git a/tools/nightly-release.sh b/tools/nightly-release.sh index ad0acbd2..d1eb0132 100755 --- a/tools/nightly-release.sh +++ b/tools/nightly-release.sh @@ -48,6 +48,14 @@ github-release upload \ --name "micro-$1-linux64.tar.gz" \ --file binaries/micro-$1-linux64.tar.gz +echo "Uploading Linux 64 static binary" +github-release upload \ + --user zyedidia \ + --repo micro \ + --tag nightly \ + --name "micro-$1-linux64-static.tar.gz" \ + --file binaries/micro-$1-linux64-static.tar.gz + echo "Uploading Linux 32 binary" github-release upload \ --user zyedidia \ diff --git a/tools/pre-release.sh b/tools/pre-release.sh index e26b09e2..9f42f57c 100755 --- a/tools/pre-release.sh +++ b/tools/pre-release.sh @@ -39,6 +39,14 @@ github-release upload \ --name "micro-$1-linux64.tar.gz" \ --file binaries/micro-$1-linux64.tar.gz +echo "Uploading Linux 64 static binary" +github-release upload \ + --user zyedidia \ + --repo micro \ + --tag $tag \ + --name "micro-$1-linux64-static.tar.gz" \ + --file binaries/micro-$1-linux64-static.tar.gz + echo "Uploading Linux 32 binary" github-release upload \ --user zyedidia \ diff --git a/tools/release.sh b/tools/release.sh index 853279b5..f806c565 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -38,6 +38,14 @@ github-release upload \ --name "micro-$1-linux64.tar.gz" \ --file binaries/micro-$1-linux64.tar.gz +echo "Uploading Linux 64 static binary" +github-release upload \ + --user zyedidia \ + --repo micro \ + --tag $tag \ + --name "micro-$1-linux64-static.tar.gz" \ + --file binaries/micro-$1-linux64-static.tar.gz + echo "Uploading Linux 32 binary" github-release upload \ --user zyedidia \