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/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: "\\\\."