diff --git a/editors/kak/a48s.kak b/editors/kak/a48s.kak new file mode 100644 index 0000000..0472602 --- /dev/null +++ b/editors/kak/a48s.kak @@ -0,0 +1,55 @@ +# ain48 assembly syntax highlighting +# put this in your autoload folder in ~/.config/kak/autoload and it should work +# note: if you are *creating* an autoload folder in that location, +# the *default* autoload scripts in /usr/share/kak/autoload will not trigger, +# so it might be a good idea to copy the contents of that directory. + +hook global BufCreate .*\.(a|ain)48(s|asm) %{ + set-option buffer filetype a48s +} + +hook global WinSetOption filetype=a48s %{ + require-module a48s + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window a48s-.+ + } +} + +hook -group a48s-highlight global WinSetOption filetype=a48s %{ + add-highlighter window/a48s ref a48s + hook -once -always window WinSetOption filetype=.* %{ + remove-highlighter window/a48s + } +} + +provide-module a48s %{ + +add-highlighter shared/a48s regions +add-highlighter shared/a48s/ region ';' '\n' fill comment +add-highlighter shared/a48s/dqstring region '"' '"' group +add-highlighter shared/a48s/dqstring/ fill string +add-highlighter shared/a48s/dqstring/ \ + regex (\\[\\abefhnrtv\n])|(\\.) 1:keyword 2:Error +add-highlighter shared/a48s/code default-region group + +# immediates +add-highlighter shared/a48s/code/ regex \ +(?i)#-?(s[0-5]+|o[0-7]+|b[01]+|x[0-9]+)\b \ +0:value + +# registers +add-highlighter shared/a48s/code/ regex (?i)%([a-z0-7]+)\b 0:builtin + +# directives +add-highlighter shared/a48s/code/ regex \.[a-zA-Z]+ 0:type + +# labels +add-highlighter shared/a48s/code/ regex ^\h*[A-Za-z0-9_.-]+: 0:operator + +# instructions +add-highlighter shared/a48s/code/ regex \ +(?i)\b((p?(add|dem|dvd|i[mp]?lg|mpl|rsd|str))|(n?[enpu]?i)|(ir|nc)?rv|(nc)?ivc|aeq|an|aut|cess|cst|dem|dst|et|(p?[sbq])?(lg|sc)|nam|nec|sim|tsc|vel)\b \ +0:keyword +# the regex is painfully long but i can't do anything about that so... + +}