From 8cfe59fcb0c8e68625607a848164197168927c3d Mon Sep 17 00:00:00 2001 From: Sidharth Kshatriya Date: Fri, 13 May 2022 12:55:23 +0530 Subject: [PATCH 1/2] 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 ' *)' + } + } +} From 70f9d8fbef47a735c2e6ef5f250afedfb2a99c65 Mon Sep 17 00:00:00 2001 From: Sidharth Kshatriya Date: Sun, 15 May 2022 11:23:06 +0530 Subject: [PATCH 2/2] OCaml: Recognize `'\"'` as a char literal and not the start of a string literal --- rc/filetype/ocaml.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/ocaml.kak b/rc/filetype/ocaml.kak index 34024c01..2968ec79 100644 --- a/rc/filetype/ocaml.kak +++ b/rc/filetype/ocaml.kak @@ -32,7 +32,7 @@ provide-module ocaml %{ add-highlighter shared/ocaml regions add-highlighter shared/ocaml/code default-region group -add-highlighter shared/ocaml/string region (?