2014-07-15 00:55:51 +04:00
|
|
|
# http://haml.info
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](haml) %{
|
|
|
|
set buffer filetype haml
|
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/ regions -default code haml \
|
2017-10-02 15:59:22 +03:00
|
|
|
comment ^\h*/ $ '' \
|
2014-07-15 00:55:51 +04:00
|
|
|
eval ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)?\{\K|#\{\K (?=\}) \{ \
|
2017-10-02 15:59:22 +03:00
|
|
|
eval ^\h*[=-]\K (?<!\|)(?=\n) '' \
|
|
|
|
coffee ^\h*:coffee\K ^\h*[%=-]\K '' \
|
|
|
|
sass ^\h*:sass\K ^\h*[%=-]\K ''
|
2014-07-15 00:55:51 +04:00
|
|
|
|
|
|
|
# Filters
|
|
|
|
# http://haml.info/docs/yardoc/file.REFERENCE.html#filters
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/haml/comment fill comment
|
2014-07-15 00:55:51 +04:00
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/haml/eval ref ruby
|
|
|
|
add-highlighter shared/haml/coffee ref coffee
|
|
|
|
add-highlighter shared/haml/sass ref sass
|
2014-07-15 00:55:51 +04:00
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/haml/code regex ^\h*(:[a-z]+|-|=)|^(!!!)$ 0:meta
|
|
|
|
add-highlighter shared/haml/code regex ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)? 1:keyword 2:variable
|
2014-07-15 00:55:51 +04:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-01-13 03:56:30 +03:00
|
|
|
def -hidden haml-filter-around-selections %{
|
2015-11-04 12:48:47 +03:00
|
|
|
# remove trailing white spaces
|
|
|
|
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d }
|
2014-07-15 00:55:51 +04:00
|
|
|
}
|
|
|
|
|
2017-01-13 03:56:30 +03:00
|
|
|
def -hidden haml-indent-on-new-line %{
|
2014-07-15 00:55:51 +04:00
|
|
|
eval -draft -itersel %{
|
2017-01-11 16:56:48 +03:00
|
|
|
# copy '/' comment prefix and following white spaces
|
2017-01-13 03:50:03 +03:00
|
|
|
try %{ exec -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P }
|
2014-07-15 00:55:51 +04:00
|
|
|
# preserve previous line indent
|
2017-01-13 03:50:03 +03:00
|
|
|
try %{ exec -draft \; K <a-&> }
|
2014-07-15 00:55:51 +04:00
|
|
|
# filter previous line
|
2017-01-13 03:56:30 +03:00
|
|
|
try %{ exec -draft k : haml-filter-around-selections <ret> }
|
2014-07-15 00:55:51 +04:00
|
|
|
# indent after lines beginning with : or -
|
2017-01-13 03:50:03 +03:00
|
|
|
try %{ exec -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> }
|
2014-07-15 00:55:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
hook -group haml-highlight global WinSetOption filetype=haml %{ add-highlighter window ref haml }
|
2014-07-15 00:55:51 +04:00
|
|
|
|
2016-09-25 16:15:07 +03:00
|
|
|
hook global WinSetOption filetype=haml %{
|
2017-01-13 03:56:30 +03:00
|
|
|
hook window InsertEnd .* -group haml-hooks haml-filter-around-selections
|
|
|
|
hook window InsertChar \n -group haml-indent haml-indent-on-new-line
|
2014-07-15 00:55:51 +04:00
|
|
|
}
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
hook -group haml-highlight global WinSetOption filetype=(?!haml).* %{ remove-highlighter window/haml }
|
2016-09-28 09:45:01 +03:00
|
|
|
|
2014-07-15 00:55:51 +04:00
|
|
|
hook global WinSetOption filetype=(?!haml).* %{
|
2017-01-04 03:07:45 +03:00
|
|
|
remove-hooks window haml-indent
|
|
|
|
remove-hooks window haml-hooks
|
2014-07-15 00:55:51 +04:00
|
|
|
}
|