Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Better support for package dependencies config (for non-dune projects) #1385

Open
MoritzHamann opened this issue Oct 3, 2024 · 0 comments

Comments

@MoritzHamann
Copy link

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:

  1. 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)
  2. 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.
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant