-
-
Notifications
You must be signed in to change notification settings - Fork 904
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
[3.16] Support semanticTokens missing methods #2448
Comments
Hey @sebastiansturm willing to take a took? specially the delta request? I implemented on clojure-lsp both range and full semantic-tokens, it's missing only the delta for full support :D |
yep, will have a look! |
if anyone would like to test this, I have a preliminary implementation at sebastiansturm/lsp-mode, but I haven't opened a PR yet as I'll need to test it with |
cool @sebastiansturm I can test it, I implemented clojure lsp server support for semantic tokens recently, but no refresh yet, but I can do if it's needed |
I noticed some bugs on lsp-mode regarding delaying the tokens updates and for a small amount of time the tokens just got white before apply the tokens instead of use the major mode faces, I hope this branch fixes it too! |
I'm not a clojure developer but I'll gladly use the clojure server for testing if you'll implement support, otherwise I'll try with the lua language server (as far as I understand, someone recently had issues with lua lsp sending out refresh requests, so apparently the support is there). |
I'm not sure when should server should send refresh notification, do you have an example? |
Hey @sebastiansturm, good news, my issue with some tokens not being updates were gone with your branch :D |
thanks for the bug report! I haven't seen this kind of behavior myself (unless, as mentioned, tree-sitter-hl was enabled), but I'll try to install clojure-lsp this evening and reproduce the issue myself. If that doesn't work out, I'll have a look this weekend at what happens with tree-sitter enabled, maybe for some reason the same underlying issue occurs with your configuration |
better take this with a large grain of salt for now, but I guess the flickering might be caused by the underlying fontification layer extending its fontification region, in which case previously inserted token faces might get cleared, but wouldn't get reinserted because lsp-semantic-tokens only considers the originally requested fontification region. I've pushed an experimental commit to my repository that should fix this (if this really is the underlying issue; but it least it did eliminate flickering during my own 5 minutes of testing) |
Ow, I'll update it here and keep testing, thanks! |
@sebastiansturm the merged branch looks better than it was on master :) But I found 2 issues:
|
as for newly inserted text remaining unfontified at first: I'll have to try this out, though it makes sense it would behave that way; if parts of the buffer had previously been fontified already, semantic highlighting will be suspended until new data arrives from the language server. On the other hand, applying default fontification unconditionally (as we now do prior to language server initialization, thanks to the patch submitted by @Kha) might clear previous semantic-highlighting tokens within the region that is to receive font locking, so this might cause lots of flickering during regular typing. as for the fragments of incorrect highlighting: have to check; are you using ranged or delta requests in that example? Maybe I messed up the implementation, will have a look (won't get to it today but hopefully on one of the next few evenings). Thanks a lot! |
yeah, that looks hard to implement but I have no idea on how to implement that so feel free to test it if it works 😅
For now, only full and range as is the supported for clojure-lsp, but I'll implement delta soon. Also, I know Dart lsp server is already using semantic tokens, so there is another server to test things: https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md |
@sebastiansturm I also noticed the faces doesn't match with current clojure major mode, do you know some way to improve the default faces for that without need to customize manually that? like macro face: keywords, and others the same, all differ from elisp faces for example. It'd be nice to use the same from the major modes to avoid those changing for users before and after LSP, WDYT? Any ideas @yyoncho ? |
@sebastiansturm I noticed lsp-mode is not updating the tokens after moving parens via paredit or something like that: I know lsp already advice some function and call rangeFormatting, we probably should update the tokens at the same time as well |
To me, this looks like a bug in the server or in the client. |
I tried to base |
I pushed a commit with some debugging helper methods that capture buffer snapshots before and after every fontification run, and export those snapshots using |
I'm just revisiting my semantic-tokens branch and for some reason |
c/c @yyoncho |
I had a look at the fontification issues using both the |
@sebastiansturm I confirmed the issue, and it seems really a issue on clojure-lsp, the issue is that clojure-lsp handle the |
@sebastiansturm I did a quick fix for this issue for now (You can test if run a |
Also I created this #2826 which solves the different faces issue :) |
lsp-put is more of a workaround and it is supposed to be avoided as much as possible. plist-put returns a new list when it is called with nil object. We might fix that limitation by making lsp-get work with |
great, happy to hear that! Will have a look now at your face overrides PR, thanks! |
thanks for clearing that up. My current use of |
@ericdallo your changes look good to me, haven't noticed any issues. I pushed an interactive function named |
Nice, I think both will work nice. I'll keep using both during the week, but semantic tokens look way better than before :) |
are tokens for "current buffer" saved somewhere / somehow? can they be available so external packages can use that info for other purposes? on that matter, when should a package use such information? should something like |
@FelipeLema we can arrange saving them and making them public.
One can implement a method - go to the next token with the same type(e. g. next variable declaration). |
I can write such "saving them and making them public" I'm interested in doing so because I'm working on implementing semanticTokens in ccls and it was pointed out that I'm leaving out a tightly-coupled feature of ccls with Emacs. I thought that a) other packages could benefit from having the current tokens b) decoupling rainbow semantic highlight from ccls-the-server and ccls-the-package is a good idea. |
ok, just coordinate your effort with @sebastiansturm I don't understand 100% what will be the use case of decoupling of the rainbow semantic highlight from ccls if only ccls can provide that data. |
I have a pending PR on semantic tokens that is a bit out of date by now and still produces some CI warnings; think it's best I'll rebase and clean up that PR on the weekend, so it can be used as a basis for @FelipeLema's potential extensions. @FelipeLema: does the ccls extension "abuse" the standard semanticTokens protocol in some way (say, by using otherwise undefined token ids), or does it transmit that extra info out of band? |
Yeah, @sebastiansturm last time I checked your PR was OK, I think if you update it, I can re-test it with Dart and Clojure and we can merge it as it improves semantic tokens, but I can't test the delta tokens yet :/ |
@sebastiansturm It does not: the extension leverages the token information to present extra meta-information to the user using fontification. I've never used it, but as far as I understand, it "rainbows elements" (like rainbow-parens) within a certain group. The code can be found here Maybe I'm missing some technical detail, but that's the core of the functionality there. The whole handling of the token information was done before LSP 3.16 so there is some intersection, although I think it should be decoupled from ccls (maybe into something like |
* adds support for delta and refresh requests. Also fixes flicker in combination with underlying highlighting mechanisms if those mechanisms were to dynamically adjust font-lock regions (clojure mode's syntax highlighter and tree-sitter-hl are prominent examples) Address #2448 Co-authored-by: Sebastian Sturm <[email protected]>
SPEC
lsp-mode is missing the implementation of:
textDocument/semanticTokens/full/delta
witch should improve performance bringing only the tokens relative to existing onesworkspace/semanticTokens/refresh
not critical, which allows server request client to refresh the tokens at any time.The text was updated successfully, but these errors were encountered: