So no. I think I'm happy with what I get from Metals for now. Just wondering where I get my syntax highlight (parser/lexer) from? Preferably with synchronous code.
well it sort of depends on how your editor does syntax highlighting
Hanns Holger Rutz
@Sciss
Currently, it just runs the lexer on the whole buffer when you edit, since that is so far a pretty fast operation. Then I get like a token iterator, and that's mapped to font attributes. I already do one extra mapping from scalariform tokens to my own, so that wouldn't be the problem.
But ideally I could distinguish whether a symbol is a class, an object, refers to a local variable or a class variable, etc. I thought that was called semantic highlight.
Ok. This is why IMHO the Scala 2 presentation compiler was such a great project (in concept). It's a shame that it didn't live on as a public and official API.
since Guillaume mentions (in 2018) ammonite for syntax highlighting, perhaps that's a better option for me than trying to depart from some JavaScript/TS code...
I believe under the hood in Amm there is a lexer of sorts that is using fansi to color stuff
Hanns Holger Rutz
@Sciss
Yes, that's just (as far as I see) the last step of converting token symbols to terminal printable colours. In my case, I am going through Java2D / Swing, so I really just need a lexer that can be configured to produce correct results for both Scala 2.13 and 3. I have to read and understand how that regex tree of the VS code project is traversed, and if those regexes in general would be easy to translate to be compatible with Java regex (and if that performs fast or not). I once had a JFlex based grammar - very fast - but it's outdated Scala 2, and I don't think I am capable of writing that for Scala 3 myself. Stuff has changed, e.g. writing numerical literals like 123_456, trailing commas etc., the syntax changed a lot in the last years.
Hanns Holger Rutz
@Sciss
It looks like well this person wrote a textmate bundle in 2017, and then I forked it from here, and pasted stuff over from this version abandoned in 2018, and I tweaked in a bit to support this Scala feature. Would be nice to have some principled and authoritative source that is a bit more concrete than a backus-naur form.