2014-07-14 22:55:51 +02:00
|
|
|
# http://haml.info
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](haml) %{
|
2017-11-03 08:34:41 +01:00
|
|
|
set-option buffer filetype haml
|
2014-07-14 22:55:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/haml regions
|
|
|
|
add-highlighter shared/haml/code default-region group
|
2018-07-02 12:59:12 +02:00
|
|
|
add-highlighter shared/haml/comment region ^\h*/ $ fill comment
|
2014-07-14 22:55:51 +02:00
|
|
|
|
|
|
|
# Filters
|
|
|
|
# http://haml.info/docs/yardoc/file.REFERENCE.html#filters
|
2018-07-02 12:59:12 +02:00
|
|
|
add-highlighter shared/haml/eval1 region -recurse \{ ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)?\{\K|#\{\K (?=\}) ref ruby
|
|
|
|
add-highlighter shared/haml/eval2 region ^\h*[=-]\K (?<!\|)(?=\n) ref ruby
|
|
|
|
add-highlighter shared/haml/coffee region ^\h*:coffee\K ^\h*[%=-]\K ref coffee
|
|
|
|
add-highlighter shared/haml/sass region ^\h*:sass\K ^\h*[%=-]\K ref sass
|
2014-07-14 22:55:51 +02:00
|
|
|
|
2018-07-01 11:53:35 +02: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-14 22:55:51 +02:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-11-03 08:34:41 +01:00
|
|
|
define-command -hidden haml-filter-around-selections %{
|
2015-11-04 10:48:47 +01:00
|
|
|
# remove trailing white spaces
|
2017-11-03 09:09:45 +01:00
|
|
|
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
|
2014-07-14 22:55:51 +02:00
|
|
|
}
|
|
|
|
|
2017-11-03 08:34:41 +01:00
|
|
|
define-command -hidden haml-indent-on-new-line %{
|
2017-11-03 09:09:45 +01:00
|
|
|
evaluate-commands -draft -itersel %{
|
2017-01-11 14:56:48 +01:00
|
|
|
# copy '/' comment prefix and following white spaces
|
2017-11-03 09:09:45 +01:00
|
|
|
try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P }
|
2014-07-14 22:55:51 +02:00
|
|
|
# preserve previous line indent
|
2017-11-03 09:09:45 +01:00
|
|
|
try %{ execute-keys -draft \; K <a-&> }
|
2014-07-14 22:55:51 +02:00
|
|
|
# filter previous line
|
2017-11-03 09:09:45 +01:00
|
|
|
try %{ execute-keys -draft k : haml-filter-around-selections <ret> }
|
2014-07-14 22:55:51 +02:00
|
|
|
# indent after lines beginning with : or -
|
2017-11-03 09:09:45 +01:00
|
|
|
try %{ execute-keys -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> }
|
2014-07-14 22:55:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
hook -group haml-highlight global WinSetOption filetype=haml %{ add-highlighter window/haml ref haml }
|
2014-07-14 22:55:51 +02:00
|
|
|
|
2016-09-25 15:15:07 +02:00
|
|
|
hook global WinSetOption filetype=haml %{
|
2018-01-21 00:35:05 +01:00
|
|
|
hook window ModeChange insert:.* -group haml-hooks haml-filter-around-selections
|
2017-01-13 01:56:30 +01:00
|
|
|
hook window InsertChar \n -group haml-indent haml-indent-on-new-line
|
2014-07-14 22:55:51 +02:00
|
|
|
}
|
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
hook -group haml-highlight global WinSetOption filetype=(?!haml).* %{ remove-highlighter window/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
|
|
|
}
|