jez/vim-better-sml

Ability to configure which CM file is loaded

jonsterling opened this issue · 2 comments

This is a great plugin! If one improvement were possible, I think I might be able to use it in my projects.

The problem is that largescale SML developments typically have a number of different CM files, and usually it is only correct for the IDE to try and load a specific one of those; indeed, sometimes we may even design a CM file specifically for the IDE to use (to the exclusion of all others!).

In particular, if you are using path anchors in a CM files, the plugin may cause syntastic to load a CM file that has an unbound anchor, rather than the master CM file that sets this anchor.

In the SML mode for VS Code, we allowed users to have a little configuration file at their project root which explains to the IDE which CM file it should use. I don't know if you want something like that here, but something that achieves the same goal would be really useful.

jez commented

👋 Thanks for the feedback! I'm always glad to hear this plugin is useful.

Some questions:

  • Do you think a simple config variable would be enough?
  • Do you have an example of one of the config files you're using with VS Code?
  • Do you know if there's a precedent for something like this with sml-mode in Emacs?

We want to balance:

  • consistency with the community
  • convenience
  • smooth onboarding for new SML users (think: freshman CS students who know little about SML much less Vim)

Happy to help implement something! I just want to make sure we strike the right balance.

Hi @jez, thanks for your response!

  1. A config variable sounds like a nice idea, but the problem is that the answer to Which .cm file should I load will always differ project-by-project, especially in cases where you are collaborating with someone who doesn't follow the same convention you do.

  2. Here's an example of one of the configuration files for VS Code in one of the @RedPRL projects: https://github.com/RedPRL/sml-typed-abts/blob/master/sml.json

  3. As far as I know, the SML Emacs mode provides no special facilities for loading things via CM, or completion via MLton dumps. It has an option to open a repl with a specified command, but it doesn't attempt to do anything fancy like inferring which file to load, or using CM. There are some current projects that attempt to use MLton's basis output option to get completion, but this is very much in development.

I think the behavior that vim-better-sml implements is suitable for students first getting started with SML; in playground-type projects, you are unlikely to have more than one CM file (and even less likely to have any complicated dependency issues that lead you to use things like CM's path anchor feature!). Usually such projects just have one .cm file which only uses Group is... and not even Library.

On the other hand, in largescale projects (like RedPRL, but probably also MLton and others), it's crucial for us to be able to break things up into multiple libraries, even within the same directory. There's no sensible way for the mode to figure out which of these it is supposed to build unless it can be configured, and this configuration would need to happen on a project-by-project basis.

Maybe one way to strike a balance would be to have the current automatic behavior be the default, but allow projects to be configured somehow so as to override it.