Skip to content

Add support for tree-sitter syntax highlighting? #111

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

Closed
atlemann opened this issue Jun 22, 2022 · 4 comments
Closed

Add support for tree-sitter syntax highlighting? #111

atlemann opened this issue Jun 22, 2022 · 4 comments

Comments

@atlemann
Copy link

Description

The syntax highlighting is a bit lacking. When VSCode added syntax APIs, Ionide used that instead of Regex and it got so much better. Would it be possible to follow the work done here: emacs-csharp/csharp-mode#201 and use https://emacs-tree-sitter.github.io for more fine grained highlighting?

Expected behavior

Detailed syntax highlighting like Ionide in VSCode

Actual behavior

Too little of the code is highlighted, but it would be nice to get e.g. types, namespaces and members in different colors.

@faldor20
Copy link
Collaborator

I've thought much the same thing, treesitter would be nice, it is accurate, fast, and requires less resources than constantly pinging the language server for semantic tokenization.
However writing a treesitter gramma is a non-trivial task, and frankly, considering it would not provide highlighting that is better than the current semantic highlighting implementation I don't feel like it's much of a priority.

Speaking of which, Is the highlighting broken for you? It should be the same as inoide.
Are you using the latest version of the extension?: https://marketplace.visualstudio.com/items?itemName=faldor20.fsharp-language-server-updated

@atlemann
Copy link
Author

I was trying to set up Emacs for F#, sorry for not clarifying that. In VSCode it looks good.

No, it does not look trivial to implement and if it's only a slight inconvenience for Emacs, then it's probably not worth the effort.

Is it possible to use this language server impl. in vanilla Emacs and not spacemacs btw.?

@faldor20
Copy link
Collaborator

Oh I see, I admit I don't know much about Emacs LSP implementation. It may also have semantic tokenisation support as an option.
This looks promising:
https://emacs-lsp.github.io/lsp-mode/page/settings/semantic-tokens/

It should work as long as you can install lsp-mode correctly. I admit my knowledge of Emacs is pretty weak though.

@atlemann
Copy link
Author

Let's just close this. It would require someone to write a tree-sitter impl. for fsharp first. Something has been started here though: https://github.com/baronfel/tree-sitter-fsharp

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

2 participants