# http://scala-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](scala) %{ set-option buffer filetype scala } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=scala %[ require-module scala hook window ModeChange pop:insert:.* -group scala-trim-indent scala-trim-indent hook window InsertChar \n -group scala-indent scala-indent-on-new-line hook window InsertChar \} -group scala-indent scala-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scala-.+ } ] hook -group scala-highlight global WinSetOption filetype=scala %{ add-highlighter window/scala ref scala hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scala } } provide-module scala %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/scala regions add-highlighter shared/scala/code default-region group add-highlighter shared/scala/string region '"' (?|<:|:>|=:=|::|&&|\|\|) 0:operator # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden scala-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden scala-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # copy // comments prefix and following white spaces try %[ execute-keys -draft k s ^\h*\K#\h* y gh j P ] # preserve previous line indent try %[ execute-keys -draft K ] # filter previous line try %[ execute-keys -draft k : scala-trim-indent ] # indent after lines ending with { try %[ execute-keys -draft k \{$ j ] ] ] define-command -hidden scala-indent-on-closing-curly-brace %[ evaluate-commands -draft -itersel %[ # align to opening curly brace when alone on a line try %[ execute-keys -draft ^\h+\}$ m s \A|.\z 1 ] ] ] ]