From 6f801c6cda41f5cc99c4bb8f8319a36fede51f23 Mon Sep 17 00:00:00 2001 From: Tony Gong Date: Sat, 4 Jun 2022 07:34:37 -0700 Subject: [PATCH] Golang separate hook group for inserting ) and } Add a separate hook group for inserting ) and } on newline because the current implementation does not work in 100% of cases and should be able to be disabled independently of copying comment characters (which is much easier in comparison to get right) if one does not care about this feature. --- rc/filetype/go.kak | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index c993c889..9df7f12c 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -22,6 +22,7 @@ hook global WinSetOption filetype=go %{ hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace hook window InsertChar \n -group go-insert go-insert-on-new-line + hook window InsertChar \n -group go-insert-closing-delimiter go-insert-closing-delimiter-on-new-line alias window alt go-alternative-file @@ -128,7 +129,11 @@ define-command -hidden go-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy // comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K/{2,}\h* yP } + ] +] +define-command -hidden go-insert-closing-delimiter-on-new-line %[ + evaluate-commands -no-hooks -draft -itersel %[ # Wisely add '}'. evaluate-commands -save-regs x %[ # Save previous line indent in register x.