@@ -65,10 +65,12 @@ user experience as close as possible to that offered by the Emacs mode
6565package] ( https://melpa.org/#/ocaml-eglot ) . ` ocaml-eglot ` is only an
6666interface between ` eglot ` (available _ out of the box_ since `emacs >=
676729.1`) and Emacs, a major mode dedicated to OCaml editing must be
68- installed (e.g. [ caml-mode ] ( https://melpa.org/#/caml ) ,
68+ installed (e.g. [ neocaml ] ( https://melpa.org/#/neocaml ) ,
6969[ tuareg] ( https://melpa.org/#/tuareg ) or
70- [ neocaml] ( https://github.com/bbatsov/neocaml ) ). Then, for example, you
71- can use
70+ [ caml-mode] ( https://melpa.org/#/caml ) ). We recommend
71+ [ neocaml] ( https://melpa.org/#/neocaml ) as it's a modern,
72+ tree-sitter-powered OCaml mode under active development. Then, for
73+ example, you can use
7274[ ` use-package ` ] ( https://www.gnu.org/software/emacs/manual/html_node/use-package/Lisp-Configuration.html )
7375to install ` ocaml-eglot ` . You will also need
7476` https://ocaml.org/p/ocaml-lsp-server/latest ` in the [ current opam
@@ -77,7 +79,19 @@ using `dune pkg` to manage your dependencies, see [Usage with `dune
7779pkg`] ( #usage-with-dune-pkg ) )
7880
7981
80- Here's an example with Tuareg already installed:
82+ Here's an example with neocaml:
83+
84+ ``` elisp
85+ (use-package ocaml-eglot
86+ :ensure t
87+ :after neocaml
88+ :hook
89+ (neocaml-base-mode . ocaml-eglot-mode)
90+ (ocaml-eglot-mode . eglot-ensure))
91+ ```
92+
93+ <details >
94+ <summary >Using Tuareg instead</summary >
8195
8296``` elisp
8397(use-package ocaml-eglot
@@ -88,6 +102,8 @@ Here's an example with Tuareg already installed:
88102 (ocaml-eglot-mode . eglot-ensure))
89103```
90104
105+ </details >
106+
91107### Foreword on configuration
92108
93109` ocaml-eglot ` is a minor mode which is grafted onto ` eglot ` (provided
@@ -105,9 +121,9 @@ Eglot provides a hook to format the buffer on saving:
105121``` diff
106122 (use-package ocaml-eglot
107123 :ensure t
108- :after tuareg
124+ :after neocaml
109125 :hook
110- (tuareg -mode . ocaml-eglot-mode)
126+ (neocaml-base -mode . ocaml-eglot-mode)
111127- (ocaml-eglot-mode . eglot-ensure))
112128+ (ocaml-eglot-mode . eglot-ensure)
113129+ (ocaml-eglot-mode . (lambda ()
@@ -124,9 +140,9 @@ and `inlay-hints`:
124140``` diff
125141 (use-package ocaml-eglot
126142 :ensure t
127- :after tuareg
143+ :after neocaml
128144 :hook
129- (tuareg -mode . ocaml-eglot-mode)
145+ (neocaml-base -mode . ocaml-eglot-mode)
130146- (ocaml-eglot-mode . eglot-ensure))
131147+ (ocaml-eglot-mode . eglot-ensure)
132148+ (eglot-managed-mode . (lambda ()
@@ -172,9 +188,9 @@ configuration in this way:
172188
173189 (use-package ocaml-eglot
174190 :ensure t
175- :after tuareg
191+ :after neocaml
176192 :hook
177- (tuareg -mode . ocaml-eglot-mode)
193+ (neocaml-base -mode . ocaml-eglot-mode)
178194- (ocaml-eglot-mode . eglot-ensure))
179195+ (ocaml-eglot-mode . eglot-ensure)
180196+ (eglot-managed-mode . (lambda () (flycheck-eglot-mode 1)))
@@ -196,15 +212,15 @@ configured in this way:
196212``` diff
197213 (use-package ocaml-eglot
198214 :ensure t
199- :after tuareg
215+ :after neocaml
200216 :hook
201- (tuareg -mode . ocaml-eglot-mode)
217+ (neocaml-base -mode . ocaml-eglot-mode)
202218- (ocaml-eglot-mode . eglot-ensure))
203219+ (ocaml-eglot-mode . eglot-ensure)
204220+ :config
205221+ (with-eval-after-load 'eglot
206222+ (add-to-list 'eglot-server-programs
207- + '(tuareg -mode . ("ocamllsp" "--fallback-read-dot-merlin")))))
223+ + '(neocaml-base -mode . ("ocamllsp" "--fallback-read-dot-merlin")))))
208224```
209225
210226### ` merlin.el ` window behavior
@@ -226,7 +242,41 @@ configuration:
226242### Recommended minimal configuration
227243
228244Here is a recommended minimal configuration to take full advantage of
229- ` ocaml-eglot ` via ` tuareg ` (and a few additional modes):
245+ ` ocaml-eglot ` via ` neocaml ` :
246+
247+ ``` elisp
248+ ;; Configure Flymake for verbose diagnostics
249+ (use-package flymake
250+ :ensure t
251+ :pin gnu
252+ :config
253+ (setq flymake-diagnostic-format-alist
254+ '((t . (origin code message)))))
255+
256+ ;; Configure neocaml
257+ (use-package neocaml
258+ :ensure t)
259+
260+ ;; Configure OCaml-eglot
261+ (use-package ocaml-eglot
262+ :ensure t
263+ :after neocaml
264+ :hook
265+ (neocaml-base-mode . ocaml-eglot-mode)
266+ (ocaml-eglot-mode . eglot-ensure)
267+ (ocaml-eglot-mode . (lambda () (add-hook #'before-save-hook #'eglot-format nil t)))
268+ :config
269+ (setq ocaml-eglot-syntax-checker 'flymake))
270+
271+ ;; Additional modes configuration
272+ (use-package opam-switch-mode
273+ :ensure t
274+ :hook
275+ (neocaml-base-mode . opam-switch-mode))
276+ ```
277+
278+ <details >
279+ <summary >Using Tuareg instead of neocaml</summary >
230280
231281``` elisp
232282;; Configure Flymake for verbose diagnostics
@@ -268,6 +318,8 @@ Here is a recommended minimal configuration to take full advantage of
268318 (add-hook 'ocaml-eglot-mode-hook 'ocp-setup-indent))
269319```
270320
321+ </details >
322+
271323Using this configuration should provide a pleasant OCaml development
272324experience in Emacs!
273325
0 commit comments