minoki / LunarML

The Standard ML compiler that produces Lua/JavaScript
MIT License
356 stars 10 forks source link

Lsp server #9

Open leiserfg opened 1 year ago

leiserfg commented 1 year ago

Is there any, or at least a hope?

minoki commented 1 year ago

Although I haven't tried it myself, there is millet.

There is a possibility that I choose to create my own language server, but the priority is currently low.

fabjan commented 11 months ago

Millet works fine for LunarML, given they can both use mlb files to figure out what files to use.

I have been playing around with LunarML and the LÖVE game engine for fun, but I eventually decided to turn the LSP off because I have not figured out how to make Millet understand the extra libraries LunarML comes with (for example the Lua structure). If anyone has the time or interest to see if I'm doing something wrong I made a small repository here where I reproduce the problem trying to combine Millet and LunarML: https://github.com/fabjan/shiny-octo-spork, the REAME tries to explain the situation and what I have tried.

I'm am not a professional SML developer, and don't have much of a clue how to glue files together for building and to make Millet understand, I have been following examples and made things work with trial and error. Maybe I'm just making some silly mistake there, or maybe they just cannot be easily integrated.

fabjan commented 11 months ago

Update on the comment above.

I had two problems:

  1. LunarML and Millet both come with their different SML basis definitions
  2. The LUA signature I extracted from the Lua basis in LunarML was not compatible with the Lua structure implementation I got when passing the --luajit option to the LunarML compiler.

One was solved by ensuring the MLB file used for Millet as the workspace root does not actually use the LunarML basis. I moved the $(SML_LIB)/basis/lua.mlb dependency out to a new MLB I called main.mlb and only use for building with LunarML.

Two was solved by iterating failing builds and commenting out the signature fields that were missing when building with --luajit

YMMV depending on what you want to build. I used --luajit because without any flags the code emitted used // which is not available in the version of Lua that comes with the LÖVE version I used. I believe my shiny-onto-spork repository linked above can use used as a reference for getting Millet working. And if someone who unlike me is a real Standard ML developer they can probably figure out how to simplify it.