# http://ponylang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](pony) %{ set buffer filetype pony } # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ addhl shared/ regions -default code pony \ double_string '"""' '"""' '' \ double_string '"' (?' 0:type addhl shared/pony/code regex '\b(${keywords})\b' 0:keyword addhl shared/pony/code regex ';' 0:keyword addhl shared/pony/code regex '^\s*|' 0:keyword addhl shared/pony/code regex '\b(${struct})\b' 0:variable addhl shared/pony/code regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin " # Highlight types and attributes printf %s " addhl shared/pony/code regex '@[\w_]+\b' 0:attribute " } # Commands # ‾‾‾‾‾‾‾‾ def -hidden pony-indent-on-new-line %{ eval -draft -itersel %{ # preserve previous line indent try %{ exec -draft K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } # copy '//' comment prefix and following white spaces # try %{ exec -draft k x s ^\h*//\h* y jgh P } # indent after line ending with : try %{ exec -draft k x (do|try|then|else|:|=>)$ j } # else, end are always de-indented try %{ exec -draft k x (else|end):$ k x s ^\h* y j x ^" J } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group pony-highlight global WinSetOption filetype=pony %{ addhl window ref pony } hook global WinSetOption filetype=pony %{ hook window InsertChar \n -group pony-indent pony-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window InsertEnd .* -group pony-indent %{ try %{ exec -draft \; s ^\h+$ d } } } hook global WinSetOption filetype=pony %{ set buffer tabstop 2 set buffer indentwidth 2 } hook -group pony-highlight global WinSetOption filetype=(?!pony).* %{ rmhl pony } hook global WinSetOption filetype=(?!pony).* %{ rmhooks window pony-indent }