fix(ocaml): Prevent clobbering +format-with globally

Previously, loading the `ocaml` module and opening a file in Tuareg mode
would result in every buffer having its formatter set to `ocp-indent`.
This now restricts the formatter override to the current buffer.
This commit is contained in:
Patrick Norton 2023-09-15 19:32:19 -07:00 committed by Henrik Lissner
parent aab5215951
commit 34f583d396

View file

@ -109,7 +109,7 @@
:config :config
;; TODO Fix region-based formatting support ;; TODO Fix region-based formatting support
(defun +ocaml-init-ocamlformat-h () (defun +ocaml-init-ocamlformat-h ()
(setq +format-with 'ocp-indent) (setq-local +format-with 'ocp-indent)
(when (and (executable-find "ocamlformat") (when (and (executable-find "ocamlformat")
(locate-dominating-file default-directory ".ocamlformat")) (locate-dominating-file default-directory ".ocamlformat"))
(when buffer-file-name (when buffer-file-name
@ -118,7 +118,7 @@
(setq-local ocamlformat-file-kind 'implementation)) (setq-local ocamlformat-file-kind 'implementation))
((equal ext ".eliomi") ((equal ext ".eliomi")
(setq-local ocamlformat-file-kind 'interface))))) (setq-local ocamlformat-file-kind 'interface)))))
(setq +format-with 'ocamlformat)))) (setq-local +format-with 'ocamlformat))))
;; Tree sitter ;; Tree sitter
(eval-when! (modulep! +tree-sitter) (eval-when! (modulep! +tree-sitter)