Closed fommil closed 1 year ago
Yep this is a great idea. @ckipp01 also seemed interested in this approach on the scala tooling discord.
Second this 👍🏽 , would love to get ENSIME working with Scala 3!
@gvolpe ensime already works on Scala 3, it is just missing this one feature.
Thanks @fommil , I mean diagnostics, saw this on the README file :)
@robmwalsh solved this, it turns out that you can ctx.typerState.setReporter
In Scala 2 I am able to get callbacks from the Reporter by hijacking it and forwarding to the existing reporter, e.g. in my plugin's init
but in Scala 3, there is no equivalent mechanism. I agree fully that this mechanism is a massive hack in Scala 2, but there's no possibility to wind back time and add APIs so it must remain. Ideally I'd be able to pass a callback to a register.
My usecase is to
tee
all the logs / diagnostics into a file, so that the ENSIME LSP can watch for changes and show diagnostics in the user's text editor. This is build tool agnostic. It also means that the diagnostics are computed on-demand by the user, and are effectively calculated "for free" since there is no separate batch or interactive compile step, saving laptop battery life.I can imagine that other kinds of tooling would want access to the reporter logs as well as ENSIME, in which case you might want to consider just offering that as a feature. But for it to work with ENSIME, the compiler plugin would need to be able to enable the feature and either specify the location of the file or obtain the location.
// @robmwalsh