2014-07-15 00:55:51 +04:00
|
|
|
# http://haml.info
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](haml) %{
|
2017-11-03 10:34:41 +03:00
|
|
|
set-option buffer filetype haml
|
2014-07-15 00:55:51 +04:00
|
|
|
}
|
|
|
|
|
2019-04-12 01:54:58 +03:00
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=haml %{
|
2019-03-14 00:00:59 +03:00
|
|
|
require-module haml
|
2019-04-12 01:54:58 +03:00
|
|
|
|
|
|
|
hook window ModeChange insert:.* -group haml-trim-indent haml-trim-indent
|
|
|
|
hook window InsertChar \n -group haml-indent haml-indent-on-new-line
|
|
|
|
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ }
|
2019-03-14 00:00:59 +03:00
|
|
|
}
|
|
|
|
|
2019-04-12 01:54:58 +03:00
|
|
|
hook -group haml-highlight global WinSetOption filetype=haml %{
|
|
|
|
add-highlighter window/haml ref haml
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haml }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-14 00:00:59 +03:00
|
|
|
provide-module haml %[
|
|
|
|
require-module ruby
|
|
|
|
require-module coffee
|
|
|
|
require-module sass
|
|
|
|
|
2014-07-15 00:55:51 +04:00
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 12:53:35 +03:00
|
|
|
add-highlighter shared/haml regions
|
|
|
|
add-highlighter shared/haml/code default-region group
|
2018-07-02 13:59:12 +03:00
|
|
|
add-highlighter shared/haml/comment region ^\h*/ $ fill comment
|
2014-07-15 00:55:51 +04:00
|
|
|
|
|
|
|
# Filters
|
|
|
|
# http://haml.info/docs/yardoc/file.REFERENCE.html#filters
|
2018-07-02 13:59:12 +03: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-15 00:55:51 +04:00
|
|
|
|
2018-07-01 12:53:35 +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
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-12-19 12:10:26 +03:00
|
|
|
define-command -hidden haml-trim-indent %{
|
2015-11-04 12:48:47 +03:00
|
|
|
# remove trailing white spaces
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
|
2014-07-15 00:55:51 +04:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden haml-indent-on-new-line %{
|
2017-11-03 11:09:45 +03:00
|
|
|
evaluate-commands -draft -itersel %{
|
2017-01-11 16:56:48 +03:00
|
|
|
# copy '/' comment prefix and following white spaces
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -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-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft \; K <a-&> }
|
2014-07-15 00:55:51 +04:00
|
|
|
# filter previous line
|
2018-12-19 12:10:26 +03:00
|
|
|
try %{ execute-keys -draft k : haml-trim-indent <ret> }
|
2014-07-15 00:55:51 +04:00
|
|
|
# indent after lines beginning with : or -
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> }
|
2014-07-15 00:55:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-14 00:00:59 +03:00
|
|
|
]
|