2014-07-14 01:53:28 +03:00
|
|
|
;;; prelude-ocaml.el --- Emacs Prelude: decent Perl coding settings.
|
|
|
|
;;
|
2015-03-03 13:04:34 +02:00
|
|
|
;; Copyright © 2014-2015 Geoff Shannon
|
2014-07-14 01:53:28 +03:00
|
|
|
;;
|
|
|
|
;; Author: Geoff Shannon <geoffpshannon@gmail.com>
|
|
|
|
;; URL: https://github.com/bbatsov/prelude
|
|
|
|
;; Version: 1.0.0
|
|
|
|
;; Keywords: convenience
|
|
|
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; tuareg is the preferred ocaml mode for Emacs
|
|
|
|
|
2014-10-24 21:30:22 +03:00
|
|
|
;; These setups for ocaml assume that you are using the OPAM package
|
|
|
|
;; manager (http://opam.ocaml.org/).
|
|
|
|
|
|
|
|
;; Because of the apparent complexity of getting emacs environment
|
|
|
|
;; variables setup to use opam correctly, it is instead easier to use
|
|
|
|
;; opam itself to execute any necessary commands.
|
|
|
|
|
|
|
|
;; Also, the standard OCaml toplevel usage has been replaced in favor
|
|
|
|
;; of UTOP, the universal toplevel, and we assume that you are using
|
|
|
|
;; the Jane Street Core libraries rather than the regular OCaml
|
|
|
|
;; standard libraries
|
|
|
|
|
|
|
|
;; The minimum required setup for using Prelude's OCaml setup would be
|
|
|
|
;; to install OPAM, and then, minimally `opam install core utop'. A
|
|
|
|
;; good getting started guide is available at
|
|
|
|
;; https://github.com/realworldocaml/book/wiki/Installation-Instructions
|
|
|
|
|
2014-07-14 01:53:28 +03:00
|
|
|
;;; License:
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or
|
|
|
|
;; modify it under the terms of the GNU General Public License
|
|
|
|
;; as published by the Free Software Foundation; either version 3
|
|
|
|
;; of the License, or (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2014-12-11 17:58:47 +02:00
|
|
|
(prelude-require-packages '(tuareg utop merlin flycheck-ocaml))
|
2014-07-14 01:53:28 +03:00
|
|
|
|
|
|
|
(require 'tuareg)
|
|
|
|
(require 'utop)
|
|
|
|
(require 'merlin)
|
|
|
|
|
|
|
|
(setq auto-mode-alist
|
|
|
|
(append '(("\\.ml[ily]?\\'" . tuareg-mode)
|
|
|
|
("\\.topml\\'" . tuareg-mode))
|
|
|
|
auto-mode-alist))
|
|
|
|
|
2014-12-11 17:58:47 +02:00
|
|
|
(with-eval-after-load 'merlin
|
|
|
|
;; Disable Merlin's own error checking
|
|
|
|
(setq merlin-error-after-save nil)
|
|
|
|
|
|
|
|
;; Enable Flycheck checker
|
|
|
|
(flycheck-ocaml-setup))
|
|
|
|
|
|
|
|
(add-hook 'tuareg-mode-hook #'utop-setup-ocaml-buffer)
|
|
|
|
(add-hook 'tuareg-mode-hook #'merlin-mode)
|
2014-07-14 01:53:28 +03:00
|
|
|
|
2014-08-05 01:44:20 +03:00
|
|
|
(add-hook 'tuareg-mode-hook (lambda ()
|
|
|
|
(progn
|
|
|
|
(define-key tuareg-mode-map (kbd "C-c C-s")
|
2014-10-18 20:36:55 +03:00
|
|
|
'utop)
|
|
|
|
(setq compile-command
|
2014-12-11 18:00:31 +02:00
|
|
|
"opam config exec corebuild "))))
|
2014-08-05 01:44:20 +03:00
|
|
|
|
2014-07-28 22:52:18 +03:00
|
|
|
;; Setup merlin completions company is used by default in prelude
|
|
|
|
(add-to-list 'company-backends 'merlin-company-backend)
|
|
|
|
|
2014-10-24 21:30:22 +03:00
|
|
|
;; Merlin also offers support for autocomplete, uncomment this next line
|
2014-07-28 22:52:18 +03:00
|
|
|
;; to activate it.
|
|
|
|
;; (setq merlin-use-auto-complete-mode t)
|
|
|
|
|
2014-12-11 18:00:31 +02:00
|
|
|
(setq utop-command "opam config exec utop -- -emacs"
|
2014-07-14 01:53:28 +03:00
|
|
|
merlin-error-after-save nil)
|
|
|
|
|
|
|
|
(provide 'prelude-ocaml)
|
|
|
|
|
|
|
|
;;; prelude-ocaml.el ends here
|