1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-26 13:02:01 +03:00

Merge remote-tracking branch 'sidkshatriya/ocaml-switch-between-ml-and-mli'

This commit is contained in:
Maxime Coste 2021-11-21 09:37:08 +11:00
commit 0e2612f1ad

View File

@ -18,7 +18,11 @@ hook global WinSetOption filetype=ocaml %{
hook -group ocaml-highlight global WinSetOption filetype=ocaml %{
add-highlighter window/ocaml ref ocaml
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ocaml }
alias window alt ocaml-alternative-file
hook -once -always window WinSetOption filetype=.* %{
unalias window alt ocaml-alternative-file
remove-highlighter window/ocaml
}
}
provide-module ocaml %{
@ -74,4 +78,22 @@ evaluate-commands %sh{
"
}
# Conveniences
# ‾‾‾‾‾‾‾‾‾‾‾‾
# C has header and source files and you need to often switch between them.
# Similarly OCaml has .ml (implementation) and .mli (interface files) and
# one often needs to switch between them.
#
# This command provides a simple functionality that allows you to accomplish this.
define-command ocaml-alternative-file -docstring 'Switch between .ml and .mli file or vice versa' %{
evaluate-commands %sh{
if [ "${kak_buffile##*.}" = 'ml' ]; then
printf "edit -- '%s'" "$(printf %s "${kak_buffile}i" | sed "s/'/''/g")"
elif [ "${kak_buffile##*.}" = 'mli' ]; then
printf "edit -- '%s'" "$(printf %s "${kak_buffile%i}" | sed "s/'/''/g")"
fi
}
}
}