-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Fallback to starting lsp-server in tmp dir #2076
Fallback to starting lsp-server in tmp dir #2076
Conversation
Should we treat |
Makes sense, added in ddefda8 |
eedab63
to
be28297
Compare
Currently we do not auto-start the lsp server if no valid clojure projects are found. This means that we won't have any lsp support for files in workspace folders that do not contain project files. This can be quite unexpected. Additionally this means we don't support lsp operations on files opened which are not part of any workspace (for example when peeking or using File > Open on a random file on the host). This commit makes two changes: + Adds a fallback behaviour of provisioning an lsp server in a OS tmp directory if no valid project is found. + Adds `.lsp/config.edn` as a heuristic for a valid clojure project. Fixes BetterThanTomorrow#2069
be28297
to
b75ad06
Compare
When I add a folder to the mono-repo workspace that does not have a Clojure project in it, a mysterious clojure-lsp server is started. Is this by design? The server remains running when I remove the non-clojure folder. When I add a clojure-project folder and then remove it, its server is also still running. I'm thinking this might be so in #2075 too, but have not yet tried it. |
I am guessing that the ”mystery” server is serving all non-clojure folders? I added an empty folder and that did not start a new one, and adding a I think this might be fine. This server is not using much memory on my machine. Maybe we can add a description to it, so that we can tell the user why it is there. Then it wouldn't be a ”mystery”, I am thinking. Is the server shared among all VS Code windows? If so it should probably always show up in the clojure-lsp menu when it is running. WDYT? |
After adding the empty folder, I have a few of these in the dev console:
|
I tried Calva: Fire up the Getting Started REPL from a new VS Code window and hoped a bit that the tmp server would be active there. It wasn't. You think it is possible to make it so? Doesn't have to be in this PR, but would be a great improvement of the Getting Started REPL experience. |
Yes, that is what this PR is adding
Adding a label is probably a good idea yes, will see what I can do
No there isn't really a way to share a process between vscode windows like that I don't think. So new windows would start new processes, just as before.
This wasn't introduced by this PR afaict. I have been intermittently getting this in my console since the start - I think it's just normal operation (vscode cancelling the request due to it being stale)
If you use We can improve on this by explicitly provisioning the fallback lsp server when running the "Fire up the Getting Started REPL" command - but lets play with that in a separate PR. |
We wouldn't need to share the process. Rather connect the client to an existing lsp server. Let's consider in a separate PR. |
While theoretically possible, I don't think the vscode lsp client library supports connecting to an independently running process, which would make implementing this hard (support would probably need to be added upstream) |
Can we connect several clients to the same server, @ericdallo ? I seem to recall having done this at some point... |
@PEZ this wouldn't be a limitation of clojure-lsp but rather of the vscode client library. Though now looking more closely at the API it seems there might be a way to pass it a read/write stream instead of a process to start. So I guess this is possible. |
Hum, probably not, could you elaborate a real example why that would make sense? |
@ericdallo in this PR we are adding so that a general clojure-lsp server is started that serves files that are not part of a clojure project. E.g. if some of the workspace root folders are not Clojure projects (no deps.edn, etc), EDN and Clojure files in there can still get clojure-lsp help. All such folders will be served by the same clojure-lsp server. (Please correct me if I describe this in the wrong way, @julienvincent.) If someone (like me) has 20 VS Code windows open, that can amount to 20 clojure-lsp servers started. It would be good if all VS Code windows could share the same ”general” clojure-lsp server. It's similar if the same Clojure project is opened in several Windows. That specific clojure-lsp server could also be shared then. |
Yes, that's what I have played with some year ago or so. |
I see, for the same project open on multiple windows, that really makes sense and should work. |
Added a description to the fallback client in the lsp management menu - f6c2a6c
Fixed in fcb7b22 |
I have updated the documentation to include a section about the fallback server behaviour. |
Co-authored-by: Peter Strömberg <pez@pezius.com>
This is tested to the best of my ability, but I may have missed something. Perhaps you can think of some scenarios that I need to test specifically? |
Tested this out on my windows VM and it seems to be working the same. The VM is super clunky which makes it difficult to test everything very well, but the temp directory stuff is working. |
Sorry for late reply. I totally missed you had been testing it, @julienvincent. (Thanks @bpringe for reminding me about it!) Let's get this merged then! I'll read up on what order we decided to do it. |
I started here. 😄 Let me know when the next PR in the pack is ready for merging. You might wanna ping me on slack, my Github feed is a bit noisy and I miss stuff. |
Currently we do not auto-start the lsp server if no valid clojure projects are found. This means that we won't have any lsp support for files in workspace folders that do not contain project files. This can be unexpected.
Additionally this means we don't support lsp operations on files opened which are not part of any workspace (for example when peeking or using File > Open on a random file on the host).
This commit makes two changes:
.lsp/config.edn
as a heuristic for a valid clojure project.Some misc changes:
Fixes #2069
Checklist
dev
branch. (Or have specific reasons to target some other branch.)published
. (Sorry for the nagging.)[Unreleased]
entry inCHANGELOG.md
, linking the issue(s) that the PR is addressing.npm run prettier-format
)npm run eslint
before creating your PR, or runnpm run eslint-watch
to eslint as you go).