fsprojects / fsharp-language-server

Other
219 stars 37 forks source link

Add support for tree-sitter syntax highlighting? #111

Closed atlemann closed 2 years ago

atlemann commented 2 years ago

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: https://github.com/emacs-csharp/csharp-mode/issues/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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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