feat(ocaml): switch to using opam-switch-mode

`tuareg-opam-update-env` has been deprecated, and the `opam-switch-mode`
package is recommended for managing opam switches. This commit adds this
package to the OCaml module
This commit is contained in:
Puneeth Chaganti 2024-04-10 17:50:14 +05:30 committed by Henrik Lissner
parent 1f404bae96
commit 046cfd816a
3 changed files with 22 additions and 5 deletions

View file

@ -20,10 +20,6 @@
;; harmless if `prettify-symbols-mode' isn't active
(setq tuareg-prettify-symbols-full t)
;; Use opam to set environment
(setq tuareg-opam-insinuate t)
(tuareg-opam-update-env (tuareg-opam-current-compiler))
(setq-hook! 'tuareg-mode-hook
comment-line-break-function #'+ocaml/comment-indent-new-line)
@ -123,6 +119,22 @@
(setq-local ocamlformat-file-kind 'interface)))))
(setq-local +format-with 'ocamlformat))))
(use-package! opam-switch-mode
:hook (tuareg-mode-local-vars . +ocaml-init-opam-switch-h)
:init
(map! :localleader
:map tuareg-mode-map
"w" #'opam-switch-set-switch)
(defun +ocaml-init-opam-switch-h ()
"Activate `opam-switch-mode' if the opam executable exists."
(when (executable-find "opam")
(opam-switch-mode)))
:config
;; Use opam to set environment
(setq tuareg-opam-insinuate t)
(opam-switch-set-switch (tuareg-opam-current-compiler)))
;; Tree sitter
(eval-when! (modulep! +tree-sitter)
(add-hook! 'tuareg-mode-local-vars-hook #'tree-sitter!))