From 9b49c5db0df7de76f299b40f2c70076ced89e64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Tue, 3 May 2022 22:11:28 -0400 Subject: [PATCH] fix single line comment behavior on insert, remove unnecessary commented blocks --- rc/filetype/javascript.kak | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 5d9059b1..33a9823d 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -56,20 +56,19 @@ define-command -hidden javascript-indent-on-char %< define-command -hidden javascript-insert-on-new-line %< evaluate-commands -draft -itersel %< execute-keys - # NOT working, copies single line comment "//" - # try %[ - # evaluate-commands -draft -save-regs '/"' %[ - # # copy the commenting prefix - # execute-keys -save-regs '' k 1s^\h*(//+\h*) y - # try %[ - # # if the previous comment isn't empty, create a new one - # execute-keys ^\h*//+\h*$ js^\h*P - # ] catch %[ - # # if there is no text in the previous comment, remove it completely - # execute-keys d - # ] - # ] - # ] + try %[ + evaluate-commands -draft -save-regs '/"' %[ + # copy the commenting prefix + execute-keys -save-regs '' k 1s^\h*(//+\h*) y + try %[ + # if the previous comment isn't empty, create a new one + execute-keys ^\h*//+\h*$ js^\h*P + ] catch %[ + # if there is no text in the previous comment, remove it completely + execute-keys d + ] + ] + ] try %[ # if the previous line isn't within a comment scope, break execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) @@ -102,8 +101,6 @@ define-command -hidden javascript-insert-on-new-line %< # align the new star with the previous one execute-keys K1s^[^*]*(\*)& ] - # # copy // comments prefix and following white spaces - # try %{ execute-keys -draft k s ^\h*\K/{2,}\h* y gh j P } > > @@ -153,14 +150,6 @@ define-command -hidden javascript-indent-on-new-line %< # Now indent and align that new line with the opening parenthesis/brace execute-keys 1 & > > - # # preserve previous line indent - # try %{ execute-keys -draft K } - # # filter previous line - # try %{ execute-keys -draft k : javascript-trim-indent } - # # indent after lines beginning / ending with opener token - # try %_ execute-keys -draft k s [[({] [\])}] j _ - # # deindent closing token(s) when after cursor - # try %_ execute-keys -draft ^\h*[})\]] gh / [})\]] m 1 _ > >