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