diff options
| author | AdriĆ Arrufat <adria.arrufat@gmail.com> | 2025-04-14 15:38:56 +0900 |
|---|---|---|
| committer | AdriĆ Arrufat <adria.arrufat@gmail.com> | 2025-04-15 12:00:50 +0900 |
| commit | d93b23b6a3c1e3c09a20bf95fa21cc71b3746c91 (patch) | |
| tree | e3e338b663d6073c09bb852f00a9ce9159660eb9 /rc | |
| parent | 922607221b8e5b2683babb9ebeba9372e97b836c (diff) | |
improve inserting comments on new lines for go
Now it matches the behavior from c-family, python, and zig
Diffstat (limited to 'rc')
| -rw-r--r-- | rc/filetype/go.kak | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index 4f8407cd..923eebaa 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -135,7 +135,15 @@ define-command -hidden go-indent-on-closing-curly-brace %[ define-command -hidden go-insert-comment-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy // comments prefix and following white spaces - try %{ execute-keys -draft <semicolon><c-s>kx s ^\h*\K/{2,}\h* <ret> y<c-o>P<esc> } + try %{ + execute-keys -draft <semicolon><c-s>kx s ^\h*\K/{2,}\h* <ret> y<c-o>P<esc> + # check for empty comments and delete them + try %{ + execute-keys kx<a-K>^\h*//+\h*$<ret> + } catch %{ + execute-keys Jx_d + } + } ] ] |
