# 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-insert scala-insert-on-new-line 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 x s \h+$ d } } define-command -hidden scala-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy // comments prefix and following white spaces try %{ execute-keys -draft kx s ^\h*\K#\h* yP } ] ] define-command -hidden scala-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # 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 x \{$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] ] ] 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 ] ] ] ]