Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More advanced syntax highlighting #9

Open
unorsk opened this issue Mar 30, 2023 · 2 comments
Open

More advanced syntax highlighting #9

unorsk opened this issue Mar 30, 2023 · 2 comments

Comments

@unorsk
Copy link
Contributor

unorsk commented Mar 30, 2023

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

  • In the unison file I somehow expected None and helloHandler to have different colors
  • But I like how function definitions differ from function declarations (this is what I am used to see it in haskell)
  • Maybe some more things I just can't spot right away
@ChrisPenner
Copy link
Contributor

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
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants