Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.1 KiB

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