Repository navigation
Semantic Highlighting: Merge rather than replace styles - #517
ahmedneilhussain wants to merge 1 commit into
Conversation
|
I'm not suggesting this fix for merge, necessarily, I'd just like some help understanding what's going on and advice about what the best behaviour should be. I think for Coco's case (non-tm4e based editor) there's no sensible thing the semantic highlighting can really do - it needs to get the colouring from somewhere! In this case, perhaps there should be a better way of disabling semantic highlighting per content type? In the LSP4e README it does say that people 'generally' pair lsp4e with tm4e, but it doesn't mandate it. I'm more unsure why I'm seeing the behaviour I am with Corrosion, since that does use tm4e AIUI. @mickaelistria can you comment, as I believe you are involved with both Corrosion and tm4e? From what the class comments say, @rubenporras , it appears the intention is that the semantic highlighting gets merged with the 'vanilla' highlighting, but the line I change looks as though it will clear any existing styling. Is it possible that the order in which the two reconciliation algorithms are applied makes a difference, and is not always predictable? Is it also possible the extent to which this is a problem will depend on the server & language: if the server provides semantic highlighting for almost every token in the document then the 'vanilla' highlighting won't ever make much difference. |
|
Semantic Highlighting uses TM4E "just" to turn the response into some styling. TM4E, when used with a grammar, also uses a TextMate grammar to everaluate the styles to apply. |
|
my first impression is that if with Corrosion almost all colors are replaced as black, that is because no stylesheet has been configured. What do you think of #522? If you think it is a valid approach, would you mind testing it with corrosion?
Regarding this, what do you think of having the possibility to contribute your own org.eclipse.lsp4e.operations.semanticTokens.TokenTypeMapper so that Semantic Highlight would work without TM4E? Regards |
Maybe this could even be an IAdapter |
|
@ahmedneilhussain , I think that semantic tokens is a more refined "tokenizer" than syntactic tokens, so if they differ on what token the editor should display, I think the semantic information should replace the syntactic one, so replace is wanted here. I will merge my PR which I think will avoid the behavior as well except for the case where an item is obsolete, there the code will still create an empty style if none is found. |
|
We can close this one now, right? |
Sure. |
@rubenporras what do you think of this?
Semantic highlighting is causing problems with Coco's eclipse plugin. We don't use TM4e on the eclipse side, we have our own editor subclass and implement the various highlighting and bracket-matching hooks directly. Semantic highlighting assumes text mate highlighting is active (not unreasonably, since there needs to be some kind of assumed presentation for the server's tokenisation!) and clobbers everything else.
However, I've also observed similar behaviour with Corrosion (the Rust plugin, which I use in my lsp4e dev workspace as a de facto test harness). When you open a document you initially get colors from the TM highlighting, but when the semantic highlighting kicks in after a second or so, almost all of the colours get replaced as black.
Before:

After short delay:

If I make the change in this PR then the result looks like this: