kakoune/rc/base/ocaml.kak

62 lines
1.8 KiB
Plaintext
Raw Normal View History

2017-02-26 21:54:06 +01:00
# http://ocaml.org
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# require ocp-indent
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.mli? %{
set buffer filetype ocaml
}
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/ regions -default code ocaml \
2017-02-26 21:54:06 +01:00
string '"' (?<!\\)(\\\\)*" '' \
comment \Q(* \Q*) '' \
add-highlighter shared/ocaml/string fill string
add-highlighter shared/ocaml/comment fill comment
2017-02-26 21:54:06 +01:00
# Commands
# ‾‾‾‾‾‾‾‾
def -hidden ocaml-indent-on-char %{
eval -no-hooks -draft -itersel %{
exec ";i<space><esc>Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}<ret>"
}
}
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ add-highlighter window 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
}
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
# ‾‾‾‾‾
%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 shared/ocaml/code regex \b($(printf $keywords | tr : '|'))\b 0:keyword
2017-02-26 21:54:06 +01:00
hook global WinSetOption filetype=ocaml %{
set window static_words $keywords
}
hook global WinSetOption filetype=(?!ocaml).* %{
unset window static_words
}
"
}