unisonweb / vscode-unison

Official Unison extension for Visual Studio Code
MIT License
23 stars 4 forks source link

More advanced syntax highlighting #9

Open unorsk opened 1 year ago

unorsk commented 1 year ago

I've noticed that syntax highlighting is a bit too simple.

Just to compare unison share and vscode highlighting:

Unison share:

Screenshot 2023-03-30 at 13 36 02

VSCode:

Screenshot 2023-03-30 at 13 36 30

Yeah, the color schemes are different, but the highlighting itself seems to be completely different too.

Is it hard to make it work similarly to unison share (and/or the haskell vscode extension)

Here's a sample for Haskell

Screenshot 2023-03-30 at 13 45 30
ChrisPenner commented 1 year ago

I think likely the best way to do this would actually be through the Semantic Tokens LSP request, since in Unison we can't know the difference between a term, type, or constructor name through syntax alone, you need access to the codebase.

It should be relatively straight-forward to analyze the Haskell type for a parsed file and produce the semantic tokens response, but we're a bit busy lately so it's unlikely to happen in the short term.

In the meantime though we'd accept reasonable updates to the Regex-based highlighting, or we'd love to have a Tree-sitter grammar if anyone's up to that task 😄

kylegoetz commented 1 year ago

For anyone reading this, I'm pretty close to being done with a tree sitter grammar at https://github.com/kylegoetz/tree-sitter-unison

(I came here because I was looking at how the VS Code plugin does highlighting for doc blocks)