# http://ponylang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](pony) %{ set-option buffer filetype pony } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=pony %{ require-module pony set-option window static_words %opt{pony_static_words} hook window InsertChar \n -group pony-insert pony-insert-on-new-line hook window InsertChar \n -group pony-indent pony-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } } hook -group pony-highlight global WinSetOption filetype=pony %{ add-highlighter window/pony ref pony hook -once -always window WinSetOption filetype=.* %{ remove-highlighter pony } } provide-module pony %{ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/pony regions add-highlighter shared/pony/code default-region group add-highlighter shared/pony/triple_string region '"""' '"""' fill string add-highlighter shared/pony/double_string region '"' (?' 0:type add-highlighter shared/pony/code/ regex '\b(${keywords})\b' 0:keyword add-highlighter shared/pony/code/ regex ';' 0:keyword add-highlighter shared/pony/code/ regex '^\s*|' 0:keyword add-highlighter shared/pony/code/ regex '\b(${struct})\b' 0:variable add-highlighter shared/pony/code/ regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin " # Highlight types and attributes printf %s " add-highlighter shared/pony/code/ regex '@[\w_]+\b' 0:attribute " } # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden pony-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy // comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } } } define-command -hidden pony-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft , K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k x s \h+$ d } # indent after line ending with : try %{ execute-keys -draft , k x (\b(?:do|try|then|else)|:|=>)$ j } # else, end are always de-indented try %{ execute-keys -draft , k x \b(else|end):$ k x s ^\h* y j x ^" J } } } }