From 6c02f80935a2fc2004630c73efe50de90f9b21b8 Mon Sep 17 00:00:00 2001 From: John Isom Date: Wed, 29 Jul 2020 21:10:43 -0600 Subject: [PATCH] Add indent-on-closing-brace rule to sass.kak --- rc/filetype/sass.kak | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rc/filetype/sass.kak b/rc/filetype/sass.kak index 403a47dd..aafe7eb1 100644 --- a/rc/filetype/sass.kak +++ b/rc/filetype/sass.kak @@ -11,15 +11,16 @@ hook global BufCreate .*[.](sass) %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook global WinSetOption filetype=sass %{ +hook global WinSetOption filetype=sass %< require-module sass hook window ModeChange pop:insert:.* -group sass-trim-indent sass-trim-indent + hook window InsertChar \} -group sass-indent sass-indent-on-closing-brace hook window InsertChar \n -group sass-indent sass-indent-on-new-line set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } -} +> hook -group sass-highlight global WinSetOption filetype=sass %{ add-highlighter window/sass ref sass @@ -27,7 +28,7 @@ hook -group sass-highlight global WinSetOption filetype=sass %{ } -provide-module sass %{ +provide-module sass %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -53,6 +54,13 @@ define-command -hidden sass-trim-indent %{ try %{ execute-keys -draft -itersel s \h+$ d } } +define-command -hidden sass-indent-on-closing-brace %< + evaluate-commands -draft -itersel %< + # align closing brace to same indentation as the line that the opening brace resides on + try %[ execute-keys -draft ^\h+\}$ m 1 ] + > +> + define-command -hidden sass-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '/' comment prefix and following white spaces @@ -66,4 +74,4 @@ define-command -hidden sass-indent-on-new-line %{ } } -} +§