diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2015-10-10 16:25:46 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2015-10-11 17:41:14 +0300 |
| commit | f2eb2e8b1cbbe71bf60f99bb576490cda164a783 (patch) | |
| tree | a1de96ee619b6f8607d47516985d988a9717e058 | |
| parent | 50f5140cbd1b85ec9b87ec4ea49328e81266afba (diff) | |
Add support for astyle code-formatting
| -rw-r--r-- | rc/c-family.kak | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/rc/c-family.kak b/rc/c-family.kak index 58ae6815..6486ab42 100644 --- a/rc/c-family.kak +++ b/rc/c-family.kak @@ -68,6 +68,17 @@ def -hidden _c-family-indent-on-closing-curly-brace %[ try %[ exec -draft "hm;<a-?>(class|struct|union)<ret><a-k>\`(class|struct|union)[^{}\n]+(\n)?\s*\{\'<ret><a-;>ma;<esc>" ] ] +decl str c_astyle_options "" +def c-format-astyle -docstring "Format C/C++/Obj-C code using the astyle utility" %{ + %sh{ + readonly x=$((kak_cursor_column - 1)) + readonly y="${kak_cursor_line}" + + echo "exec -draft %{%|astyle<space>${kak_opt_c_astyle_options// /<space>}<ret>}" + echo "exec gg ${y}g ${x}l" + } +} + # Regions definition are the same between c++ and objective-c %sh{ for ft in c cpp objc; do @@ -122,13 +133,18 @@ hook global WinSetOption filetype=(c|cpp|objc) %[ alias window alt c-family-alternative-file alias window comment-selection c-family-comment-selection + + alias window format-code c-format-astyle ] hook global WinSetOption filetype=(?!(c|cpp|objc)$).* %[ - rmhooks window c-family-indent rmhooks window c-family-hooks + rmhooks window c-family-indent + unalias window alt c-family-alternative-file unalias window comment-selection c-family-comment-selection + + unalias window format-code ] hook global WinSetOption filetype=c %[ addhl ref c ] |
