From c0e402c06f3047cca36d3bfccb0dfab681052d1c Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Sun, 26 Feb 2017 21:54:06 +0100 Subject: [PATCH] add rc/ocaml.kak --- rc/base/ocaml.kak | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 rc/base/ocaml.kak diff --git a/rc/base/ocaml.kak b/rc/base/ocaml.kak new file mode 100644 index 00000000..8f298c6a --- /dev/null +++ b/rc/base/ocaml.kak @@ -0,0 +1,61 @@ +# http://ocaml.org +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# require ocp-indent + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*\.mli? %{ + set buffer filetype ocaml +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter -group / regions -default code ocaml \ + string '"' (?Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}" + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ add-highlighter ref ocaml } + +hook global WinSetOption filetype=ocaml %{ + hook window InsertChar [|\n] -group ocaml-indent ocaml-indent-on-char +} + +hook -group ocaml-highlight global WinSetOption filetype=(?!ocaml).* %{ remove-highlighter ocaml } + +hook global WinSetOption filetype=(?!ocaml).* %{ + remove-hooks window ocaml-indent +} + +# Macro +# ‾‾‾‾‾ + +%sh{ + 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 " + add-highlighter -group /ocaml/code regex \b($(printf $keywords | tr : '|'))\b 0:keyword + hook global WinSetOption filetype=ocaml %{ + set window static_words $keywords + } + hook global WinSetOption filetype=(?!ocaml).* %{ + unset window static_words + } + " +}