From 8cfe59fcb0c8e68625607a848164197168927c3d Mon Sep 17 00:00:00 2001 From: Sidharth Kshatriya Date: Fri, 13 May 2022 12:55:23 +0530 Subject: [PATCH] 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 --- rc/filetype/ocaml.kak | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rc/filetype/ocaml.kak b/rc/filetype/ocaml.kak index ffafcfe3..34024c01 100644 --- a/rc/filetype/ocaml.kak +++ b/rc/filetype/ocaml.kak @@ -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\(\*' + execute-keys ' *)' + } + } +}