2017-02-26 21:54:06 +01:00
|
|
|
# http://ocaml.org
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# require ocp-indent
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*\.mli? %{
|
2017-11-03 08:34:41 +01:00
|
|
|
set-option buffer filetype ocaml
|
2017-02-26 21:54:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/ocaml regions
|
|
|
|
add-highlighter shared/ocaml/code default-region group
|
|
|
|
add-highlighter shared/ocaml/string region '"' (?<!\\)(\\\\)*" '' fill string
|
|
|
|
add-highlighter shared/ocaml/comment region \Q(* \Q*) '' fill comment
|
2017-02-26 21:54:06 +01:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-11-03 08:34:41 +01:00
|
|
|
define-command -hidden ocaml-indent-on-char %{
|
2017-11-03 09:09:45 +01:00
|
|
|
evaluate-commands -no-hooks -draft -itersel %{
|
|
|
|
execute-keys ";i<space><esc>Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}<ret>"
|
2017-02-26 21:54:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ add-highlighter window/ocaml ref ocaml }
|
2017-02-26 21:54:06 +01:00
|
|
|
|
|
|
|
hook global WinSetOption filetype=ocaml %{
|
|
|
|
hook window InsertChar [|\n] -group ocaml-indent ocaml-indent-on-char
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
hook -group ocaml-highlight global WinSetOption filetype=(?!ocaml).* %{ remove-highlighter window/ocaml }
|
2017-02-26 21:54:06 +01:00
|
|
|
|
|
|
|
hook global WinSetOption filetype=(?!ocaml).* %{
|
|
|
|
remove-hooks window ocaml-indent
|
|
|
|
}
|
|
|
|
|
|
|
|
# Macro
|
|
|
|
# ‾‾‾‾‾
|
|
|
|
|
2018-05-06 23:29:52 +02:00
|
|
|
evaluate-commands %sh{
|
2017-02-26 21:54:06 +01:00
|
|
|
keywords=and:as:asr:assert:begin:class:constraint:do:done:downto:else:end:exception:external:false:for:fun:function:functor:if:in:include:inherit:initializer:land:lazy:let:lor:lsl:lsr:lxor:match:method:mod:module:mutable:new:nonrec:object:of:open:or:private:rec:sig:struct:then:to:true:try:type:val:virtual:when:while:with
|
|
|
|
echo "
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/ocaml/code/ regex \b($(printf $keywords | tr : '|'))\b 0:keyword
|
2017-02-26 21:54:06 +01:00
|
|
|
hook global WinSetOption filetype=ocaml %{
|
2017-11-03 08:34:41 +01:00
|
|
|
set-option window static_words $keywords
|
2017-02-26 21:54:06 +01:00
|
|
|
}
|
|
|
|
"
|
|
|
|
}
|