-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
LSP support for multi-project and multi-workspace #2020
LSP support for multi-project and multi-workspace #2020
Conversation
2a96b9c
to
00f555b
Compare
FYI I will be rebasing all these commits back together once approved before merging. |
3b93fef
to
248ad06
Compare
Thanks for sharing of your work and time with Calva! I love the changes! Some initial thoughts after having tried it very briefly with the
Which I think is fine. There's a Opening Comments on this menu:
General Ux comments:
I think I found some bugs:
|
I'll look more at this, and the code changes later tonight. |
Two things on this point:
Yea this does make sense, I can add this.
Thanks, fixed in e29c53c
Ok, changed in f197bc4 |
The clojure-lsp statusbar item disappears when some view that is not in the project is focused. Like the an Output channel. |
|
Single-project workspaces:
|
I guess this tells us we need an integration test for single-project workspaces. Not sure how to do that, though, maybe we need two different runs. |
@julienvincent Thanks for working on this. I started to review but figured I'd wait until some of the feedback @PEZ provided is addressed first. |
@julienvincent In the future, please leave the relevant checklist from the PR template in the PR description. It helps us make sure everything we want to check/do per PR is checked/done. |
Sure, I have re-added it now. |
This is expected as the
Resolved in a94457b
Resolved in 947c56b
I can't reproduce this - what exactly are you doing to trigger? And in which project?
Also can't reproduce this, need some more info
Resolved in fa2d38f |
Expected, maybe, but surprising. 😄 If I stop it, I expect it to stay stopped. I think we need a setting like
It's in single-project repos. Opening any project from
Again, single project workspaces. Did you catch that heading? |
Yes I tried in a single project workspace - it works on my machine haha
I really can't reproduce this (before or after latest commits). |
So with the new architecture there isn't really a concept of a sub-server - all servers are treated the same and I think this is a good thing. It makes sense to me to rename the setting as you say - although I would leave it on by default as that closest matches the existing Calva behaviour. |
I added something to this effect now in 995b865. Instead of buttons I used a two phase selection menu which I think is more accessible to keyboard users. Give it a try let me know what you think. |
All servers are not treated equally on startup. When I open |
This is the same behaviour when opening a file after startup. The current auto-start logic works by finding the root most valid clojure project. So even if opening a subdirectory it should still start the server at the root (if it is a valid project). I thought this made the most sense as a default behaviour for automatic starting as it feels like the most desirable action. But I'm not too sure, maybe it needs to be more configurable
Interesting.. this might be a nice behaviour. How would we keep track? |
There is global storage where we can save things keyed on workspace. But I guess the question isn't about what is used to keep track, but rather how we make sure the right state is saved? ... Tricky to get right, probably... Maybe we can do something less magic, and let the user choose which servers should autostart? |
We could consider waiting with this, and either:
|
I tracked down the flaky status-bar reporting and fixed it in 6c66e7e |
Personally I think we should wait on it and see what feedback we get. I think the current behaviour is pretty close to how Calva works now in most cases. I think the only noticeable difference in behaviour for single workspaces projects is that the lsp server will auto-start itself even if it has been stopped (but only if a new files is opened). I don't think this will have too much of an impact. The main differences lie in the multi-workspace/project workflows which aren't currently supported (and so unlikely anyone is using Calva like this)
The issue with this approach is that we would be back to not supporting multi-workspace/multi-project as the server Calva was starting was not correctly located. We could try locate all projects and start a server there but I think this would be a bad idea as we would potentially be spawning a lot of processes that aren't used. |
We could potentially detect where servers were started previously by searching for I think though that maybe better to do this type of behaviour optimisation in a follow up project. |
I see. I've been wondering about those. 😄 Missed the first memo. For the record, I'd prefer just regular commits telling what they contain, rather than directives. So that I can read the conversation thread here easily. And we seldom do much clean-up of the commit history. We just merge it all in, as is. |
Right now Calva only supports opening clojure projects from the root of the project. This will be where the LSP process is started and the clojure LSP needs a deps.edn/project.clj file to exist at it's root in order to provide proper completions. This also means that multi-workspace setups in VSCode is not really supported. This commit refactors the LSP implementation to allow provisioning multiple LSP clients at different roots. Dependent systems can then request the LSP client governing a particular file/directory. This change simultaneously allows opening directories that contain multiple projects as well as setting up multi-workspace vscode configurations. The LSP initialization logic is also altered such that the server is started when a clojure file is opened rather than when Calva initializes. This prevents poluting non-clojure projects with .lsp and .clj-kondo directories. Closes BetterThanTomorrow#934 Closes BetterThanTomorrow#1706
This commit updates the `enableClojureLspOnStart` setting to allow specifying different auto-start behaviours. The setting now accepts the values: - "when-workspace-opened-use-workspace-root" - "when-file-opened-use-furthest-project" - "never" - true - false And has slightly different behaviours in each case. The value `true` is now an alias for `"when-workspace-opened-use-workspace-root"`, and `false` for `"never"`. When set to `"when-workspace-opened-use-workspace-root"` the clojure-lsp will be automatically started in the root of all open/added workspaces when calva initializes and whenever a workspace is added to vscode. When set to `"when-file-opened-use-furthest-project"` then the clojure-lsp will be automatically started whenever a clojure file is opened. The server will be started in the furthest possible valid clojure project or will fall back to starting in the workspace root if no valid clojure project is found. When set to `"never"` the clojure-lsp will never automatically be started and is instead left up to the user to explicitly start it in a directory.
ec782ad
to
87ab72c
Compare
The conversation thread should still read the same - the intermediary commits referenced in comments are still viewable. |
I've rebased - unless there are any further concerns I think this is ready to go :) will be giving it a final test over today. |
Well, I've been seeing |
And we generally try to avoid force pushes, just FYI. 😄 |
Here we go! 🚀 Thanks for this hard and most excellent work, @julienvincent! 🙏 ❤️ I enjoyed it, and learnt a lot in the process. |
This resolves a regression from BetterThanTomorrow#2020 which prevents certain vscode operations such as organise-imports and add-missing-import from functioning correctly. This was a result of disabling the automatic command registrations being performed by the lsp client. Originally it was assumed that these commands were unused, however they are used internally by vscode to handle their native organise-imports and related operations. This is now fixed by manually registering the missing commands with the added functionality of multi-client support. Addresses BetterThanTomorrow#2041 Fixes BetterThanTomorrow#2040
The clojure-lsp refactor project in BetterThanTomorrow#2020 reworked the way the project picker menus work, adding additional information on a second line indicating which files contributed to a folder being picked as a valid clojure project. This turned out significant hurt the UX experience in workspaces with many clojure projects. This commit removes the additional information from the picker menus, shrinking the list items to a single line. Some other smaller changes included: - Projects are now grouped by their workspace root which should help make it easier to sort through the list visually. - Project folders are now sorted within their groups to make the list more deterministic. - Project folders show the path relative to the workspace root instead of the absolute path. This should help make scanning the list easier by removing unnecessary/duplicate information. Addresses BetterThanTomorrow#2041 Closes BetterThanTomorrow#2043
This resolves a regression from BetterThanTomorrow#2020 which prevents certain vscode operations such as organise-imports and add-missing-import from functioning correctly. This was a result of disabling the automatic command registrations being performed by the lsp client. Originally it was assumed that these commands were unused, however they are used internally by vscode to handle their native organise-imports and related operations. This is now fixed by manually registering the missing commands with the added functionality of multi-client support. Addresses BetterThanTomorrow#2041 Fixes BetterThanTomorrow#2040
The clojure-lsp refactor project in BetterThanTomorrow#2020 reworked the way the project picker menus work, adding additional information on a second line indicating which files contributed to a folder being picked as a valid clojure project. This turned out significant hurt the UX experience in workspaces with many clojure projects. This commit removes the additional information from the picker menus, shrinking the list items to a single line. Some other smaller changes included: - Projects are now grouped by their workspace root which should help make it easier to sort through the list visually. - Project folders are now sorted within their groups to make the list more deterministic. - Project folders show the path relative to the workspace root instead of the absolute path. This should help make scanning the list easier by removing unnecessary/duplicate information. Addresses BetterThanTomorrow#2041 Closes BetterThanTomorrow#2043
This resolves a regression from BetterThanTomorrow#2020 which prevents certain vscode operations such as organise-imports and add-missing-import from functioning correctly. This was a result of disabling the automatic command registrations being performed by the lsp client. Originally it was assumed that these commands were unused, however they are used internally by vscode to handle their native organise-imports and related operations. This is now fixed by manually registering the missing commands with the added functionality of multi-client support. Addresses BetterThanTomorrow#2041 Fixes BetterThanTomorrow#2040
The clojure-lsp refactor project in BetterThanTomorrow#2020 reworked the way the project picker menus work, adding additional information on a second line indicating which files contributed to a folder being picked as a valid clojure project. This turned out significant hurt the UX experience in workspaces with many clojure projects. This commit removes the additional information from the picker menus, shrinking the list items to a single line. Some other smaller changes included: - Projects are now grouped by their workspace root which should help make it easier to sort through the list visually. - Project folders are now sorted within their groups to make the list more deterministic. - Project folders show the path relative to the workspace root instead of the absolute path. This should help make scanning the list easier by removing unnecessary/duplicate information. Addresses BetterThanTomorrow#2041 Closes BetterThanTomorrow#2043
The clojure-lsp refactor project in BetterThanTomorrow#2020 reworked the way the project picker menus work, adding additional information on a second line indicating which files contributed to a folder being picked as a valid clojure project. This turned out significant hurt the UX experience in workspaces with many clojure projects. This commit removes the additional information from the picker menus, shrinking the list items to a single line. Some other smaller changes included: - Projects are now grouped by their workspace root which should help make it easier to sort through the list visually. - Project folders are now sorted within their groups to make the list more deterministic. - Project folders show the path relative to the workspace root instead of the absolute path. This should help make scanning the list easier by removing unnecessary/duplicate information. Addresses BetterThanTomorrow#2041 Closes BetterThanTomorrow#2043
Fix clojure-lsp regressions from #2020
A regression introduced in BetterThanTomorrow#2020 and BetterThanTomorrow#2046 prevented the clojure-lsp and repl jack-in operations from working correctly on Windows hosts. This fixes the way we handle Uri's to make the unix and windows behaviours consistent. Fixes BetterThanTomorrow#2054
Right now Calva only supports opening clojure projects from the root of the project. This will be where the LSP process is started and the clojure LSP needs a deps.edn/project.clj file to exist at it's root in order to provide proper completions.
This also means that multi-workspace setups in VSCode is not really supported.
This commit refactors the LSP implementation to allow provisioning multiple LSP clients at different roots. Dependent systems can then request the LSP client governing a particular file/directory.
This change simultaneously allows opening directories that contain multiple projects as well as setting up multi-workspace vscode configurations.
The LSP initialization logic is also altered such that the server is started when a clojure file is opened rather than when Calva initializes. This prevents poluting non-clojure projects with
.lsp
and.clj-kondo
directories.UX
Commands
The LSP lifecycle commands have been reworked to make a bit more sense within the new architecture:
The
start
command now list all discovered clojure project roots in the workspace, allowing the user to pick where they want to start an LSP client.This is especially useful in mono-repos where a user might want to pick if they want to start the LSP at the project root or within a specific sub-package (or maybe a combination of both).
The
restart/stop
commands now list the directories mapping to running LSP clients and allows the user to select the client they want to restart/stop.Status Bar and Menu
The lsp status bar item now tracks the currently active editor. As the user changes the active window the status bar will show the status of the lsp governing the file they have open.
When the user clicks the status bar item we now show a single type of LSP menu instead of dynamically changing it based on the status of the client. This is because there are now multiple LSP clients running.
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.ci/circleci: build
test.npm run prettier-format
)npm run eslint
before creating your PR, or runnpm run eslint-watch
to eslint as you go).