Hi there,
I wonder if there are people out there who would be interested to help with the creation of a “sufficiently comfortable” embeddable mini-IDE for Scala. By this, I understand a project that can be used as a library to add IDE-like functionality to applications (in my case, desktop applications, but it could be generic and include the possibility of web applications as well), such as embedding an editor component for Scala code.
So far I have used a library called ScalaInterpreterPane which wraps SyntaxPane (formerly JSyntaxPane), using a JFlex based lexer, and coupling to an IMain
for interpreter type functionality and auto-completion. This works “ok” but doesn’t satisfy the “sufficiently comfortable” criterion. From my point of view, the goals and features should include:
- must be usable as library, thrown into a project using standard
libraryDependencies += ...
- must be usable with a virtual file system (e.g. in-memory source code)
- must have basic syntax highlight
- must have auto-completion
- must be able to handle “framing”, i.e. massage the source code with surrounding scaffold before compilation (scastie and scala-fiddle do this AFAIK)
- should have semantic highlight (e.g. extended colour coding and font attributes depending on the symbol at hand)
- should have diagnostics (“red squiggles” and/or possibility to navigate from compile errors to source locations)
- should have go-to-symbol (within the same source code, perhaps also into libraries)
- should have documentation hover or look-up (scaladoc or similar)
- should have basic refactoring (e.g. rename symbol, add explicit type)
- should have decent editor formatting and navigation functionality (e.g. auto indentation, matching brackets)
- should work with Scala 2.11, 2.12, 2.13
- should support, at later point, hybrid editing such as worksheet, jupyter style notebook
For a descent starting point, I think Pavel Fatin’s ToyIDE is great. It mimicks multiple things we know from IntelliJ and has an acceptable editor component. If you are interested to join but do not want to be tied to Swing, we could introduce an abstraction layer so that both Swing and HTML/CSS could be the target UI.
When I say mini-IDE, it’s clear this is not intended to compete with a fully-fledged IDE, that’s also not doable with limited resources. But it should be modular so that specific assumptions are only served by higher-level layers. For example, if you need a build system with multiple source files etc., and this should go, e.g., through Bloop, then this would be an optional layer. I think a good image of what it could be would be the type of IDE you have for Processing or Arduino.
My assessment of the current situation is that:
- Metals would probably be nice and interesting at some point
- but currently the overhead of developing an LSP client and probably having to work on multiple
PR to get the minimum layer working (e.g. without requiring a full build system with physical directory,
being able to package everything into one library without other local installs, in-process communication)
is too high. So we should observe its development, but not necessarily start with it. - Scala-IDE is a complex code base, but the principle idea of using the nsc.interactive.Global Scala
presentation compiler is not wrong. It gives auto-completion and it probably the entry point for
semantic highlight and refactoring. - We can probably learn some things from scastie, scala-fiddle, Scala-IDE, ammonite, etc.
Is anyone up for such a project?