-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Semantic tokens in HLS #1654
Comments
|
I'm not sure if an implementation in HLS would be worth it. Syntax highlighting already works quite well for most editors. Implementing it using an IDE sounds like a lot of work for little gain:
|
Another thing, we can't really distinguish between data types, type synonyms, type families and classes using the results of the parsing phase. If we want these to be highlighted differently, we would have to use results from the renaming phase, which would put a serious speed-bump in everything. I suppose we could use stale renaming data and accept the occasional inaccuracy, but again this is tricky to implement correctly. |
Hmm, I think maybe I've missed something here. I thought that this was additional to the basic syntax highlighting, rather than replacing it entirely? So we could just, say, emit some tokens for deprecated items, and the rest would all follow the normal syntax highlighting. Of course, the spec doesn't really make it clear... If it's an optional extra, then we can probably live with it being slower and waiting for renaming/typechecking in order to update it. I agree that wouldn't be acceptable if that was for the base level of highlighting. |
I believe the feature is all about semantic highlighting, which may takes a bit longer than a normal syntax highlighting, but it's OK as far as there is normal syntax highlighting. |
haskell lsp already has support for this |
The good thing about using the standard tokens and modifiers as much as possible, is better support for themes, more themes that only support the standard tokens/modifiers will have good enough Haskell highlight out of the box |
I was asked to provide a list of things that seemed like useful semantic highlights for Haskell here. Generally, I think it would make sense to tell things apart that are not already distinguished by Haskell's syntax. By default, Haskell has two namespaces, used in value and type positions, and lexical features (capitalization) are used to distinguish various kinds of names. But in recent Haskell, some of these distinctions break down, as things cross from values to types and the interleavings become more complicated. Even in Haskell 98, type synonyms are written the same way as other types, but they behave a bit differently. Here are some examples of things that might be useful with semantic highlighting:
Basically, the idea is to find things that can be confusing when writing code, and provide a means of communicating information to resolve that confusion without looking at docs or scrolling up to some enclosing code. |
I can't wait but working on a draft of semantic tokens.
Hope you guys could give me advices since I am quite new to hls. |
Closing this since we have an implementation! Let's make specific tickets for further improvements. |
I've got an open PR for semantic tokens support in
lsp
.This is for tracking what we'd need to do to use it in HLS.
hls-plugin-api
model of everything being provided as plugin methods? I'm not sure how well that will work, because a) combining results from multiple plugins won't be nice, since the tokens will all be using relative positions (we could absolutize them, combine them, and then relativize them again, though), and b) if you want to do the delta support then you need state, result ids, all that fun stuff that is probably much easier with a single provider of highlighting.ghcide
?The text was updated successfully, but these errors were encountered: