From ffdab1aeb389f0d4912995ed8670d55a2b050880 Mon Sep 17 00:00:00 2001 From: lisael Date: Tue, 17 Jan 2017 09:48:48 +0100 Subject: [PATCH 1/3] added https://github.com/ponylang/ponyc filetype --- rc/extra/pony.kak | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 rc/extra/pony.kak diff --git a/rc/extra/pony.kak b/rc/extra/pony.kak new file mode 100644 index 00000000..2c863a7a --- /dev/null +++ b/rc/extra/pony.kak @@ -0,0 +1,113 @@ +# http://ponylang.org +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*[.](pony) %{ + set buffer filetype pony +} + +hook global BufOpen .*[.](pony) %{ + set buffer filetype pony + echo -debug "BufOpen" +} + +hook global BufNew .*[.](pony) %{ + set buffer filetype pony +} + +# Highlighters & Completion +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code pony \ + double_string '"""' '"""' '' \ + double_string '"' (?' 0:type + addhl -group /pony/code regex '\b(${keywords})\b' 0:keyword + addhl -group /pony/code regex ';' 0:keyword + addhl -group /pony/code regex '^\s*|' 0:keyword + addhl -group /pony/code regex '\b(${type_decl})\b' 0:identifier + addhl -group /pony/code regex '\b(${struct})\b' 0:identifier + addhl -group /pony/code regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin + " + + # Highlight types and attributes + printf %s " + addhl -group /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 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 +} From eeedd4854cbdeef42de8d2c73bffda749d887cf9 Mon Sep 17 00:00:00 2001 From: lisael Date: Fri, 20 Jan 2017 13:51:25 +0100 Subject: [PATCH 2/3] Cleanups and added `:$` as autoindent trigger --- rc/extra/pony.kak | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/rc/extra/pony.kak b/rc/extra/pony.kak index 2c863a7a..a5f577b6 100644 --- a/rc/extra/pony.kak +++ b/rc/extra/pony.kak @@ -10,7 +10,6 @@ hook global BufCreate .*[.](pony) %{ hook global BufOpen .*[.](pony) %{ set buffer filetype pony - echo -debug "BufOpen" } hook global BufNew .*[.](pony) %{ @@ -40,13 +39,12 @@ addhl -group /pony/comment fill comment keywords="${keywords}|recover|consume|error|do|then|if|while" func_decl="new|fun|be|lambda" capabilities="iso|ref|box|tag|val|trn" - type_decl="class|actor|interface|trait|primitive|type" - struct="${type_decl}|var|let|embed" + struct="class|actor|interface|trait|primitive|type|var|let|embed" # Add the language's grammar to the static completion list static_words="${values}:${meta}:${keywords}:${types_decl}:${capabilities}" - static_words="${static_words}:${type_decl}:${struct}" + static_words="${static_words}::${struct}" printf %s\\n "hook global WinSetOption filetype=pony %{ set window static_words '${static_words}' }" | sed 's,|,:,g' @@ -61,7 +59,6 @@ addhl -group /pony/comment fill comment addhl -group /pony/code regex '\b(${keywords})\b' 0:keyword addhl -group /pony/code regex ';' 0:keyword addhl -group /pony/code regex '^\s*|' 0:keyword - addhl -group /pony/code regex '\b(${type_decl})\b' 0:identifier addhl -group /pony/code regex '\b(${struct})\b' 0:identifier addhl -group /pony/code regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin " @@ -84,7 +81,7 @@ def -hidden pony-indent-on-new-line %{ # 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 } + 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 } }