From 0c1f58ad896052f0c7fbb8bb4e86a299eb32584e Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Mon, 14 Jul 2014 22:53:47 +0200 Subject: [PATCH] add rc/sass.kak --- rc/sass.kak | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 rc/sass.kak diff --git a/rc/sass.kak b/rc/sass.kak new file mode 100644 index 000000000..f1f61ab53 --- /dev/null +++ b/rc/sass.kak @@ -0,0 +1,71 @@ +# http://sass-lang.com +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-sass %{ + set buffer filetype sass +} + +hook global BufCreate .*[.](sass) %{ + set buffer filetype sass +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code sass \ + string '"' (? + # remove trailing white spaces + try %{ exec -draft s \h+$ d } + } +} + +def -hidden _sass_indent_on_new_line %{ + eval -draft -itersel %{ + # preserve previous line indent + try %{ exec -draft K } + # filter previous line + try %{ exec -draft k : _sass_filter_around_selections } + # copy '/' comment prefix and following white spaces + try %{ exec -draft k x s ^\h*\K/\h* y j p } + # avoid indent after properties and comments + try %{ exec -draft k x [:/] j } + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=sass %{ + addhl ref sass + + hook window InsertEnd .* -group sass-hooks _sass_filter_around_selections + hook window InsertChar \n -group sass-indent _sass_indent_on_new_line +} + +hook global WinSetOption filetype=(?!sass).* %{ + rmhl sass + rmhooks window sass-indent + rmhooks window sass-hooks +}