You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've started to use OCaml as a scripting solution, by creating a custom toplevel with additional libraries preloaded (similar to the idea mentioned in https://blog.janestreet.com/ocaml-as-a-scripting-language/). The toplevel is created via the toplevel stanza in dune and then globally installed via opam. This works as expected by setting the first line of the scripts to
#!/usr/bin/env mytop
let()=
...
However, ocamllsp reports those additional libraries as unbound (which is expected). With the current dune setup, it should be trivial to create a .merlin file with the corresponding PKG ... line. However, the current --fallback-read-dot-merlin flag does not allow to specify the location of the .merlin file. I.e. the file has to live next to the script itself. This also falls short if scripts with different toplevels are stored in the same location.
I could see different solutions:
ocamllsp is able to detect the use of a custom toplevel and is able to extract the additional libraries available (I'm not sure if that is even possible)
Provide a setting in didChangeConfiguration to load a list of additional packages. It would be up to the editor integration to detect the custom toplevel usage and provide the additional packages during LSP initialisation.
Provide a way to specify the location of the .merlin file to use with --fallback-read-dot-merlin.
I understand that this is a somewhat fringe use case, but it would nonetheless be great if ocamllsp could support it as well.
The text was updated successfully, but these errors were encountered:
I've started to use OCaml as a scripting solution, by creating a custom toplevel with additional libraries preloaded (similar to the idea mentioned in https://blog.janestreet.com/ocaml-as-a-scripting-language/). The toplevel is created via the
toplevel
stanza in dune and then globally installed via opam. This works as expected by setting the first line of the scripts toHowever, ocamllsp reports those additional libraries as unbound (which is expected). With the current dune setup, it should be trivial to create a
.merlin
file with the correspondingPKG ...
line. However, the current--fallback-read-dot-merlin
flag does not allow to specify the location of the.merlin
file. I.e. the file has to live next to the script itself. This also falls short if scripts with different toplevels are stored in the same location.I could see different solutions:
didChangeConfiguration
to load a list of additional packages. It would be up to the editor integration to detect the custom toplevel usage and provide the additional packages during LSP initialisation..merlin
file to use with--fallback-read-dot-merlin
.I understand that this is a somewhat fringe use case, but it would nonetheless be great if ocamllsp could support it as well.
The text was updated successfully, but these errors were encountered: