From 399aece4e7294ecd9dba1562660fae83cd037f6f Mon Sep 17 00:00:00 2001 From: Sangwoo Joh Date: Wed, 4 Mar 2020 19:35:31 +0900 Subject: [PATCH 1/2] Add OCamlformat into tools list --- emacs/emacs.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/emacs/emacs.ml b/emacs/emacs.ml index 39d6e07..48e50fa 100644 --- a/emacs/emacs.ml +++ b/emacs/emacs.ml @@ -345,9 +345,19 @@ module Merlin = struct let pre_remove = [] end +module Ocamlformat = struct + (* Handled dynamically, invalid in other switches *) + let name = "ocamlformat" + let chunks = [] + let files = [] + let post_install = [] + let pre_remove = [] +end + let tools = [ (module Tuareg : ToolConfig); (module OcpIndent : ToolConfig); (module OcpIndex : ToolConfig); (module Merlin : ToolConfig); + (module Ocamlformat : ToolConfig); ] From 34166bc523346b28a1dd97e66fc33943fc59873c Mon Sep 17 00:00:00 2001 From: Sangwoo Joh Date: Wed, 4 Mar 2020 19:35:38 +0900 Subject: [PATCH 2/2] Add opam-setup-ocamlformat into .emacs --- emacs/emacs.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/emacs/emacs.ml b/emacs/emacs.ml index 48e50fa..3297f29 100644 --- a/emacs/emacs.ml +++ b/emacs/emacs.ml @@ -225,12 +225,19 @@ let base_setup = (autoload 'utop-minor-mode "utop" "Minor mode for utop" t) (add-hook 'tuareg-mode-hook 'utop-minor-mode)) +(defun opam-setup-ocamlformat () + (load (concat opam-share "/emacs/site-lisp/ocamlformat")) + (opam-setup-add-ocaml-hook + (lambda () + (define-key tuareg-mode-map (kbd "C-c C-f") #'ocamlformat)))) + (defvar opam-tools '(("tuareg" . opam-setup-tuareg) ("ocp-indent" . opam-setup-ocp-indent) ("ocp-index" . opam-setup-ocp-index) ("merlin" . opam-setup-merlin) - ("utop" . opam-setup-utop))) + ("utop" . opam-setup-utop) + ("ocamlformat" . opam-setup-ocamlformat))) (defun opam-detect-installed-tools () (let*