@@ -64,6 +64,33 @@ To add the language server to an esy project, run in terminal:
6464$ esy add @opam/ocaml-lsp-server
6565```
6666
67+ #### Dune
68+
69+ If you are using [ Dune for package
70+ management] ( https://dune.readthedocs.io/en/stable/explanation/package-management.html )
71+ on the [ latest nightly build] ( https://preview.dune.build/ ) or version 3.21 or
72+ later, you can install ` ocamllsp ` locally within the current project by
73+ running:
74+ ``` sh
75+ $ dune tools install ocamllsp
76+ ```
77+
78+ This will compile ` ocamllsp ` with the same OCaml compiler as the project itself -
79+ a requirement for ` ocamllsp ` to be able to analyze the code in the project.
80+
81+ To make sure your editor sees the correct instance of ` ocamllsp ` for the
82+ project, run ` eval $(dune tools env) ` from your shell before launching your
83+ editor from the same shell. This can be automated by adding `eval $(dune tools
84+ env)` to a ` .envrc` file in the project's root directory and using
85+ [ direnv] ( https://direnv.net ) . Editors that aren't launched from the terminal
86+ require plugin support to locate the appropriate ` ocamllsp ` executable
87+ installed by Dune. For VSCode use the [ OCaml
88+ Platform] ( https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform )
89+ plugin, and for Emacs use the
90+ [ ocaml-eglot] ( https://github.com/tarides/ocaml-eglot ) package and follow
91+ [ these] ( https://github.com/tarides/ocaml-eglot?tab=readme-ov-file#usage-with-dune-pkg )
92+ instructions.
93+
6794### Installing from sources
6895
6996This project uses submodules to handle dependencies. This is done so that users
0 commit comments