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.

90 lines
3.0 KiB

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