# Crystal # https://crystal-lang.org hook global BufCreate '.*\.cr' %{ set-option buffer filetype crystal } hook global WinSetOption filetype=crystal %{ require-module crystal add-highlighter window/ ref crystal hook -group crystal window InsertChar '\n' crystal-new-line-inserted hook -always -once window WinSetOption filetype=.* %{ remove-highlighter window/crystal remove-hooks window crystal } } provide-module crystal %[ add-highlighter shared/crystal regions add-highlighter shared/crystal/code default-region group add-highlighter shared/crystal/code/keywords regex '\b(abstract|alias|annotation|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|false|for|fun|if|include|instance_sizeof|is_a?|lib|macro|module|next|nil|nil?|of|offsetof|out|pointerof|private|protected|require|rescue|responds_to?|return|select|self|sizeof|struct|super|then|true|type|typeof|uninitialized|union|unless|until|verbatim|when|while|with|yield)\b' 0:keyword add-highlighter shared/crystal/string region '"' '(?') # Remove empty line indent try %(execute-keys -draft 'ks^\h+$d') } define-command -hidden crystal-fetch-keywords %{ set-register dquote %sh{ curl --location https://github.com/crystal-lang/crystal/raw/master/src/compiler/crystal/syntax/lexer.cr | kak -f '%1scheck_ident_or_keyword\(:(\w+\??), \w+\)y%aa|sort' } } ]