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.
This commit is contained in:
parent
f4e4d6234b
commit
6f801c6cda
|
@ -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 <semicolon><c-s>k<a-x> s ^\h*\K/{2,}\h* <ret> y<c-o>P<esc> }
|
||||
]
|
||||
]
|
||||
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user