-
-
Notifications
You must be signed in to change notification settings - Fork 898
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
Tree sitter compatibility w/ semantic tokens #2834
Comments
could you please try that with PR #2790? That should improve semhl compatibility with underlying font-lock mechanisms. Also, I guess it might matter in what order tree-sitter-hl-mode and lsp are enabled; during my personal tests, I typically activated tree-sitter first, lsp thereafter |
I pinned my lsp-mode package in doom to The order might matter, but I'm not sure how I can control that within doom. Ideally, it should not matter, of course. |
Something I noticed (even in the PR branch) not related with tree-sitter is that if you write new text, there will be no face applied to the text until client receive the semantic tokens response, it'd be really nice if we keep using the emacs(maybe tree sitter) face and only after the response apply the face |
strange, I just tried this both with C++ (clangd) and rust (rust-analyzer), with both tree-sitter and (the PR's) semantic fontification enabled. In both cases I'm seeing semantic highlights + tree-sitter highlights (tree-sitter where no semantic tokens are available, otherwise semhl wins). |
I'm also using master (+nativecomp), +pgtk so should be pretty close to your setup |
Offtopic: you are on the bleeding edge - how does pgtk feel? |
I won't be able to look further into this until a bit later, but it is worth mentioning that I'm toggling Indeed, I just confirmed that after enabling tree-sitter, if I restart the lsp server, it properly redraws the semantic hl. This is still using the PR so I can't confirm if it works without it. I'm not sure what the solution to this problem looks like - maybe having a hook to redraw the semhl whenever font lock changes drastically. |
I'm afraid I can't really judge pgtk's merits because I'm not using Wayland, and I didn't have any UI-toolkit-related performance issues with non-pgtk to start with. That being said, I haven't noticed any way in which it's worse than non-pgtk, nor did I encounter any instabilities, so I just keep using it for the time being. Maybe if there's some reliable childframe-related benchmark (something with lsp signatures perhaps?) I could run that on both branches and see if there is a difference |
Is this issue still present? |
I believe this should be fixed; @theol0403 do you agree? |
Haven't used emacs for a bit - I'll try to check later tonight 👍 |
I'm sorry, I must have made a mistake then when I retried yesterday. Will have another look tomorrow and make sure to get lsp/tree-sitter initialization order "right" (as in, "fault-triggering"). Sorry again for wasting your time @theol0403 |
I've had another look today and as @theol0403 says, tree-sitter-hl will override lsp-mode's semantic highlighting if enabled after lsp-mode (for good reason, as tree-sitter-hl covers all the highlighting provided by typical font-lock implementations).
This appears to work AFAICT (@theol0403: would be nice if you could check if that works for you, too), but personally I hate it. With both lsp and doom-emacs trying so hard to avoid unnecessary overhead, I wouldn't really like to be disabling and re-enabling heavyweight modes such as lsp just to get around a relatively minor configuration issue. Though my hope is that the in-your-face warning message would at least guide users toward the preferred activation order, while also providing them with a working setup out of the box in case they can't be bothered to work on their Emacs config the very moment they run into this issue. With that rationalization, I might be able to convince myself that this is a (borderline) acceptable solution; @yyoncho @ericdallo what is your opinion? Also, if we decide to do this, is this the best way to cleanly disable and re-enable lsp-mode? |
Do we need to disable and enable again the whole lsp-mode? can't we do that only for lsp-semantic-tokens-mode? Regarding the warning message, IMO it makes sense, users will only fix their config or what they want when seeing warnings like that if that really means there is something that should be fixed/improved on user-config. |
yes, after posting that it dawned on me that calling |
Putting the code snippet shown above in my config works as expected. Thanks! |
@theol0403 could you also try this somewhat less heavyweight version? Thanks!
|
Also seems to work well 👍 |
Nice, since this should only enable/disable semantic tokens mode, I'm ok with that :) |
I use semantic highlighting to improve the coloring of my c++ files. I was looking for better syntax hl for non-semantic identifiers and found tree-sitter.
However, when tree sitter is enabled, all semantic highlights disappear. Even for identifiers that don't have a tree sitter face assigned to them, the semhl face is still gone. It would be ideal if semhl would override tree-sitter.
Default font-lock:
Semhl:
Semhl + tree-sitter:
As you can see, the orange parameter semhl is removed. Running
describe-char
on the most-bottom "spline" identifier in the screenshot shows that there is no tree-sitter face being assinged to it, yet the semhl face is removed.Semhl:
Semhl + tree-sitter:
Which Language Server did you use
Clangd 12
OS
Fedora 35 w/ doom-emacs w/ ptk-nativecomp from git tree.
Thanks!
The text was updated successfully, but these errors were encountered: