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

OCaml: Automatically insert closing comment when user starts a comment

An OCaml comment is `(* Some comment *)`. Like the C-family this can be
a multiline comment.

Recognize when the user is trying to commence a comment when they type `(*` and
then automatically insert `*)` on behalf of the user. A small convenience.

Co-authored-by: Maxime Coste <mawww@kakoune.org>
This commit is contained in:
Sidharth Kshatriya 2022-05-13 12:55:23 +05:30
parent 459c6f589f
commit 8cfe59fcb0

View File

@ -97,3 +97,16 @@ define-command ocaml-alternative-file -docstring 'Switch between .ml and .mli fi
}
}
# The OCaml comment is `(* Some comment *)`. Like the C-family this can be a multiline comment.
#
# Recognize when the user is trying to commence a comment when they type `(*` and
# then automatically insert `*)` on behalf of the user. A small convenience.
hook global WinSetOption filetype=ocaml %{
hook window InsertChar '\*' %{
try %{
execute-keys -draft 'HH<a-k>\(\*<ret>'
execute-keys ' *)<left><left><left>'
}
}
}