Closed evanlouie closed 9 months ago
Can you reproduce this in a minimal project and share it? Easier to reason about what could be going wrong that way.
https://github.com/BetterThanTomorrow/calva/assets/48989967/f561beaa-2dee-4752-bc8c-874066253d0e
This is happening to me since this morning I updated the pluggin. Once highlight goes all white it doesn't go back.
Thanks for the report @EvaMarco! Can test with the Github Dark Default theme? That way I can compare with what I see.
With that theme I see this, but I don't know if it changes or not
Thanks! I can reproduce this in some projects, but not in others. Since the problem just recently showed up, it could be something is glitching in VS Code. We should probably check the VS Code issues for recent reports on similar things.
Since it differs between projects it could also be something with the clojure-lsp config different between the projects.
@ericdallo:
Do you have any idea what to look for in the logs or server info or lsp server config for any clues?
Tokens and scopes for a keyword in a project where it doesn't work:
The data from the lsp scopes request:
[13, 4, 16, 0, 0, 7, 1, 5, 3, 0, 0, 6, 13, 2, 1, 0, 15, 10, 6, 0, 1, 3, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 3, 2, 0, 0, 5, 9, 6, 0, 0, 32, 4, 1, 0, 0, 4, 1, 8, 0, 0, 1, 7, 2, 0, 0, 9, 10, 6, 0, 1, 10, 10, 6, 0, 0, 12, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 2, 2, 0, 0, 3, 9, 6, 0, 3, 28, 9, 7, 0, 1, 10, 6, 6, 0, 0, 8, 7, 2, 0, 0, 28, 10, 6, 0, 1, 5, 3, 3, 0, 0, 4, 6, 2, 1, 0, 7, 6, 6, 0, 1, 4, 6, 6, 0, 2, 1, 5, 3, 0, 0, 6, 11, 2, 1, 1, 3, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 3, 2, 0, 0, 5, 6, 6, 0, 0, 8, 4, 1, 0, 0, 4, 1, 8, 0, 0, 1, 12, 2, 0, 1, 10, 5, 6, 0, 0, 7, 3, 2, 0, 0, 5, 2, 3, 0, 0, 4, 5, 6, 0, 1, 24, 6, 1, 0, 0, 6, 1, 8, 0, 0, 1, 13, 2, 0, 0, 14, 5, 6, 0, 1, 21, 6, 6, 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, 3, 13, 2, 0, 1, 3, 2, 3, 0, 0, 4, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 3, 2, 0, 0, 4, 7, 2, 0, 1, 7, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 4, 2, 0, 0, 7, 14, 2, 0, 0, 15, 1, 6, 0]
I pasted the same file content in a project where keywords are correctly highlighted:
Scopes request data:
[13, 4, 16, 0, 0, 1, 4, 7, 4, 0, 0, 19, 2, 4, 0, 1, 27, 2, 4, 0, 1, 27, 2, 4, 0, 1, 29, 2, 4, 0, 1, 25, 2, 4, 0, 2, 1, 5, 3, 0, 0, 6, 13, 2, 1, 0, 15, 10, 6, 0, 1, 3, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 3, 2, 0, 0, 5, 9, 6, 0, 0, 11, 6, 1, 0, 0, 6, 1, 8, 0, 0, 1, 12, 2, 0, 0, 14, 4, 1, 0, 0, 4, 1, 8, 0, 0, 1, 7, 2, 0, 0, 9, 10, 6, 0, 1, 10, 10, 6, 0, 0, 12, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 2, 2, 0, 0, 3, 9, 6, 0, 1, 27, 6, 1, 0, 0, 6, 1, 8, 0, 0, 1, 21, 2, 0, 2, 28, 9, 7, 0, 1, 10, 6, 6, 0, 0, 8, 7, 2, 0, 0, 28, 10, 6, 0, 1, 5, 3, 3, 0, 0, 4, 6, 2, 1, 0, 7, 6, 6, 0, 1, 4, 6, 6, 0, 2, 1, 5, 3, 0, 0, 6, 11, 2, 1, 1, 3, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 3, 2, 0, 0, 5, 6, 6, 0, 0, 8, 4, 1, 0, 0, 4, 1, 8, 0, 0, 1, 12, 2, 0, 1, 10, 5, 6, 0, 0, 7, 3, 2, 0, 0, 5, 2, 3, 0, 0, 4, 5, 6, 0, 1, 24, 6, 1, 0, 0, 6, 1, 8, 0, 0, 1, 13, 2, 0, 0, 14, 5, 6, 0, 1, 21, 6, 6, 0, 1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 13, 2, 0, 1, 3, 2, 3, 0, 0, 4, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 3, 2, 0, 0, 4, 7, 2, 0, 1, 7, 1, 1, 0, 0, 1, 1, 8, 0, 0, 1, 4, 2, 0, 0, 22, 1, 6, 0, 1, 3, 3, 4, 0]
This happened to me with the last version of VSCode and the previous one.
In the project where this is not working for me, the keywords sometimes are correctly highlighted when I activate the file. Only sometimes. Editing the file immediately breaks the highlighting. Attaching a part of the lsp message log that spans such a working->not-working transition:
Highlighting seems works to correctly if the file is under the src
directly. If the file is at the root or any other directory, the highlighting fails.
https://github.com/BetterThanTomorrow/calva/assets/2081587/541bb880-a6df-43b6-b12b-7653ca4cbf4f
Can you reproduce this in a minimal project and share it? Easier to reason about what could be going wrong that way.
@PEZ Here is a sample repo showing the bug (same one shown in the video): https://github.com/evanlouie/calva-keyword-bug
It's not a bug that the semantic highlighting doesn't work outside the source paths, though. That's how clojure-lsp works. It limits its analysis to the source paths, which is a good thing.
You should be able to get highlighting to work in the root path there by adding a deps.edn
file with this content:
{:paths ["." "src"]}
Then restart the clojure-lsp server.
@EvaMarco , that's something for you to check too. That the file you are expecting highlighting to work in, is in a project source path.
The files that are failing are all under the SRC folder, but not only directly, but also inside other subfolders.
It also happens to me that sometimes when I open a file the highlight looks fine and as soon as I edit it, it fails.
Thanks! Sub folders is fine.
I think we have a bug somewhere, but it is a bit unclear where in the stack it lives. I'll get back with more questions and things to try when I come up with theories.
Actually...
The files that are failing
Do you see this in some files, and not in others?
I just checked and no, all files in my project are falling, those under src (is where I'm working on) and the rest under folders like test or something like this. Some time when I change the theme un vscode, I can see the colors in the right way, but when I focus the file, highlight breaks again.
Is there any repro project? I can't repro that with emacs, so my guess is it's a vscode bug, I could test with calva and emacs in a sample project to confirm that, but one thing is to check if clojure-lsp is receiving the semanticTokens/full request and responding to that as well
I might be able to create a repro project from the project I have where this doesn't work. As for checking if clojure-lsp is receiving the request, I've checked that. It is. It's the response that is different. It's a bit hidden in this comment: https://github.com/BetterThanTomorrow/calva/issues/2337#issuecomment-1798011645
Hum, can anyone test with previous clojure-lsp version?
Right now I can't repro this with latest clojure-lsp in the project where I saw this...
@EvaMarco how are the source paths in your project configured?
You can see our Open Source project here https://github.com/penpot/penpot
Awesome, @EvaMarco! It's so much easier to help with open source projects.
I think I see what the issue is. You are opening the repository from the repository root, right? There is no project file there for clojure-lsp to figure out the which files to analyze. This effects much more than syntax highlighting, so it is important to fix to get full leverage of Calva and clojure-lsp.
I sent a pull request with the change:
https://github.com/penpot/penpot/pull/3794
You can try it yourself by adding a deps.edn
file in the reporsitory root with this content:
;; This file exists to make clojure-lsp serve the whole repository
{:deps
{dev/frontend {:local/root "frontend"}
dev/backend {:local/root "backend"}
dev/common {:local/root "common"}
dev/exporter {:local/root "exporter"}}}
Then reload the VS Code window.
An alternative way to solve the issue, which I think is not as good, is to start the clojure-lsp server in the sub-project you are working with. Say you are working with frontend
. Then click the clojure-lsp button in the status bar and select the fronted directory to start a clojure-lsp serving that sub project only.
NB: I think it is much better to have a server serving the whole repository. So that PR is the way to go, imo. Just letting you know you have options.
The second option is what I tried, stop clojure-lsp on the project and active only on frontend but then I get these errors
And all code start to show errors like this
I'm trying to solution in my local and let the team know about your PR¡¡ Thanks.
I've tried your solution on my local and it takes a bit more time to be ready, but it's working better now¡¡¡ Thanks
Great! Thanks for reporting back about it.
The errors you got there look like a glitch with how the OS starts VS Code (and any developer editor) that sometimes do not give them the correct environment. I always start VS Code from the command line, with the code
executable (which VS Code has a command for installing).
Nice to know, I used to click in the menu icon to open code, I'll try next time the command line. FYI I work on linux, maybe it has something to do with it.
I'm closing this, as it seems it was about not providing correct configuration to clojure-lsp. Thanks all for helping in figuring this out! ❤️ 🙏
Running into an issue where keywords aren't being syntax highlighted correctly. All other highlighting is working properly.
Issues:
https://github.com/BetterThanTomorrow/calva/assets/2081587/0aa40c56-7976-42ba-afb3-42e0350ab73a