
<lexer>
  <config>
    <name>Kakoune</name>
    <alias>kak</alias>
    <alias>kakoune</alias>
    <alias>kakrc</alias>
    <alias>kakscript</alias>
    <filename>*.kak</filename>
    <filename>kakrc</filename>
    <mime_type>application/x-sh</mime_type>
    <mime_type>application/x-shellscript</mime_type>
    <mime_type>text/x-shellscript</mime_type>
  </config>
  <rules>
    <state name="root">
      <rule pattern="\b(add\-highlighter|alias|arrange\-buffers|buffer|buffer\-next|buffer\-previous|catch|change\-directory|colorscheme|debug|declare\-option|declare\-user\-mode|define\-command|complete\-command|delete\-buffer|delete\-buffer!|echo|edit|edit!|enter\-user\-mode|evaluate\-commands|execute\-keys|fail|hook|info|kill|kill!|map|nop|on\-key|prompt|provide\-module|quit|quit!|remove\-highlighter|remove\-hooks|rename\-buffer|rename\-client|rename\-session|require\-module|select|set\-face|set\-option|set\-register|source|trigger\-user\-hook|try|unalias|unmap|unset\-face|unset\-option|update\-option|write|write!|write\-all|write\-all\-quit|write\-quit|write\-quit!)\b"><token type="Keyword"/></rule>
      <rule pattern="\b(global|buffer|window|current|normal|insert|prompt|goto|view|user|object|number\-lines|show\-matching|show\-whitespaces|fill|regex|dynregex|group|flag\-lines|ranges|line|column|wrap|ref|regions|region|default\-region|replace\-ranges)\b"><token type="NameAttribute"/></rule>
      <rule pattern="\b(int|bool|str|regex|int\-list|str\-list|completions|line\-specs|range\-specs|str\-to\-str\-map)\b"><token type="NameClass"/></rule>
      <rule pattern="\b(default|black|red|green|yellow|blue|magenta|cyan|white|yes|no|false|true)\b"><token type="Literal"/></rule>
      <rule pattern="\brgba?:[0-9a-fA-F]{6,8}\b"><token type="LiteralNumberHex"/></rule>
      <rule pattern="(-params )(\b\d+)(\.\.)(\d+\b)"><bygroups><token type="Text"/><token type="LiteralNumber"/><token type="Text"/><token type="LiteralNumber"/></bygroups></rule>
      <rule pattern="&quot;(&quot;&quot;|[^&quot;])*&quot;"><token type="LiteralString"/></rule>
      <rule pattern="&#x27;(&#x27;&#x27;|[^&#x27;])*&#x27;"><token type="LiteralString"/></rule>
      <rule><include state="basic"/></rule>
      <rule pattern="`"><token type="LiteralStringBacktick"/><push state="backticks"/></rule>
      <rule><include state="data"/></rule>
      <rule><include state="interp"/></rule>
    </state>
    <state name="interp">
      <rule pattern="\$\(\("><token type="Keyword"/><push state="math"/></rule>
      <rule pattern="\$\("><token type="Keyword"/><push state="paren"/></rule>
      <rule pattern="\$\{#?"><token type="LiteralStringInterpol"/><push state="curly"/></rule>
      <rule pattern="\$[a-zA-Z_]\w*"><token type="NameVariable"/></rule>
      <rule pattern="\$(?:\d+|[#$?!_*@-])"><token type="NameVariable"/></rule>
      <rule pattern="\$"><token type="Text"/></rule>
    </state>
    <state name="basic">
      <rule pattern="\b(if|fi|else|while|in|do|done|for|then|return|function|case|select|break|continue|until|esac|elif)(\s*)\b"><bygroups><token type="Keyword"/><token type="TextWhitespace"/></bygroups></rule>
      <rule pattern="\b(alias|bg|bind|builtin|caller|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|time|times|trap|true|type|typeset|ulimit|umask|unalias|unset|wait)(?=[\s)`])"><token type="NameBuiltin"/></rule>
      <rule pattern="\A#!.+\n"><token type="CommentHashbang"/></rule>
      <rule pattern="#.*\n"><token type="CommentSingle"/></rule>
      <rule pattern="\\[\w\W]"><token type="LiteralStringEscape"/></rule>
      <rule pattern="(\b\w+)(\s*)(\+?=)"><bygroups><token type="NameVariable"/><token type="TextWhitespace"/><token type="Operator"/></bygroups></rule>
      <rule pattern="[\[\]{}()=]"><token type="Operator"/></rule>
      <rule pattern="&lt;&lt;&lt;"><token type="Operator"/></rule>
      <rule pattern="&lt;&lt;-?\s*(\&#x27;?)\\?(\w+)[\w\W]+?\2"><token type="LiteralString"/></rule>
      <rule pattern="&amp;&amp;|\|\|"><token type="Operator"/></rule>
    </state>
    <state name="data">
      <rule pattern="(?s)\$?&quot;(\\.|[^&quot;\\$])*&quot;"><token type="LiteralStringDouble"/></rule>
      <rule pattern="&quot;"><token type="LiteralStringDouble"/><push state="string"/></rule>
      <rule pattern="(?s)\$&#x27;(\\\\|\\[0-7]+|\\.|[^&#x27;\\])*&#x27;"><token type="LiteralStringSingle"/></rule>
      <rule pattern="(?s)&#x27;.*?&#x27;"><token type="LiteralStringSingle"/></rule>
      <rule pattern=";"><token type="Punctuation"/></rule>
      <rule pattern="&amp;"><token type="Punctuation"/></rule>
      <rule pattern="\|"><token type="Punctuation"/></rule>
      <rule pattern="\s+"><token type="TextWhitespace"/></rule>
      <rule pattern="\d+\b"><token type="LiteralNumber"/></rule>
      <rule pattern="[^=\s\[\]{}()$&quot;\&#x27;`\\&lt;&amp;|;]+"><token type="Text"/></rule>
      <rule pattern="&lt;"><token type="Text"/></rule>
    </state>
    <state name="string">
      <rule pattern="&quot;"><token type="LiteralStringDouble"/><pop depth="1"/></rule>
      <rule pattern="(?s)(\\\\|\\[0-7]+|\\.|[^&quot;\\$])+"><token type="LiteralStringDouble"/></rule>
      <rule><include state="interp"/></rule>
    </state>
    <state name="curly">
      <rule pattern="\}"><token type="LiteralStringInterpol"/><pop depth="1"/></rule>
      <rule pattern=":-"><token type="Keyword"/></rule>
      <rule pattern="\w+"><token type="NameVariable"/></rule>
      <rule pattern="[^}:&quot;\&#x27;`$\\]+"><token type="Punctuation"/></rule>
      <rule pattern=":"><token type="Punctuation"/></rule>
      <rule><include state="root"/></rule>
    </state>
    <state name="paren">
      <rule pattern="\)"><token type="Keyword"/><pop depth="1"/></rule>
      <rule><include state="root"/></rule>
    </state>
    <state name="math">
      <rule pattern="\)\)"><token type="Keyword"/><pop depth="1"/></rule>
      <rule pattern="\*\*|\|\||&lt;&lt;|&gt;&gt;|[-+*/%^|&amp;&lt;&gt;]"><token type="Operator"/></rule>
      <rule pattern="\d+#[\da-zA-Z]+"><token type="LiteralNumber"/></rule>
      <rule pattern="\d+#(?! )"><token type="LiteralNumber"/></rule>
      <rule pattern="0[xX][\da-fA-F]+"><token type="LiteralNumber"/></rule>
      <rule pattern="\d+"><token type="LiteralNumber"/></rule>
      <rule pattern="[a-zA-Z_]\w*"><token type="NameVariable"/></rule>
      <rule><include state="root"/></rule>
    </state>
    <state name="backticks">
      <rule pattern="`"><token type="LiteralStringBacktick"/><pop depth="1"/></rule>
      <rule><include state="root"/></rule>
    </state>
  </rules>
</lexer>

