Skip to content
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

Fix clojure-lsp regressions from #2020 #2046

Merged
merged 8 commits into from Feb 1, 2023

Conversation

julienvincent
Copy link
Contributor

@julienvincent julienvincent commented Jan 30, 2023

This is a collection of fixes which should resolve the regressions and issues reported as a result of #2020.

  • When using the "when-workspace-opened-use-workspace-root" setting the clojure-lsp server is only started in valid clojure workspaces.
  • Ensures that operations like Organise Imports continue to work. This was an unforeseen side-effect of disabling the dynamic lsp command registrations the client was performing. This default behaviour is still disabled, but now we manually register the commands (once) and augment them with support for selecting the correct lsp client to forward the request to.
  • The project selection menus have been cleaned up and had some behavioural tweaks. See below:

Project Menus

There were a few changes made to the project menus:

  • The second line containing details on why the project was considered has been removed.
  • 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.

When sorting projects the behaviour is as follows:

  • The workspace group containing the preselected project is sorted to the top.
  • The projects within each group are sorted such that the workspace root is first, the preselected item is second and then the remaining items are sorted by path length.

image

Checklist

  • Read How to Contribute.
  • Directed this pull request at the dev branch. (Or have specific reasons to target some other branch.)
  • Made sure I have changed the PR base branch, so that it is not published. (Sorry for the nagging.)
  • Updated the [Unreleased] entry in CHANGELOG.md, linking the issue(s) that the PR is addressing.
  • Figured if anything about the fix warrants tests on Mac/Linux/Windows/Remote/Whatever, and either tested it there if so, or mentioned it in the PR.
  • Added to or updated docs in this branch, if appropriate
  • Tests
    • Tested the particular change
    • Figured if the change might have some side effects and tested those as well.
    • Smoke tested the extension as such.
    • Tested the VSIX built from the PR (so, after you've submitted the PR). You'll find the artifacts by clicking Show all checks in the CI section of the PR page, and then Details on the ci/circleci: build test.
  • Referenced the issue I am fixing/addressing in a commit message for the pull request.
    • If I am fixing the issue, I have used GitHub's fixes/closes syntax
    • If I am fixing just part of the issue, I have just referenced it w/o any of the "fixes” keywords.
  • Created the issue I am fixing/addressing, if it was not present.
  • Formatted all JavaScript and TypeScript code that was changed. (use the prettier extension or run npm run prettier-format)
  • Confirmed that there are no linter warnings or errors (use the eslint extension, run npm run eslint before creating your PR, or run npm run eslint-watch to eslint as you go).

Ping @PEZ, @bpringe, @corasaurus-hex, @Cyrik

When the `"when-workspace-opened-use-workspace-root"` setting is enabled
the clojure-lsp is started in _all_ workspace roots open instead of only
valid clojure project roots.

This commit reworks this behaviour to first check if the workspace root
is a valid Clojure project before attempting to auto-start the lsp
server.

Addresses BetterThanTomorrow#2041
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
@PEZ
Copy link
Collaborator

PEZ commented Jan 30, 2023

Thanks! To my testing this works as you advertise.

I think that tucking the project file to the end of the path can get a bit confusing. E.g. here the shadow-w-backend project has several project files, deps.edn, project.clj, and shadow-cljs.edn. As a user I wonder what does it mean that deps.edn is included in the path?

image

@julienvincent
Copy link
Contributor Author

julienvincent commented Jan 30, 2023

I think that tucking the project file to the end of the path can get a bit confusing. E.g. here the shadow-w-backend project has several project files, deps.edn, project.clj, and shadow-cljs.edn. As a user I wonder what does it mean that deps.edn is included in the path?

Oops this is a bug :) will fix.

Resolved in 13d539f

@PEZ
Copy link
Collaborator

PEZ commented Jan 30, 2023

  • When using the "when-workspace-opened-use-workspace-root" setting the clojure-lsp server is only started in valid clojure workspaces.

This changes how it behaves today when opening a folder w/o a Clojure project at the root. Not sure we should necessarily keep that behaviour (ought to be pretty uncommon, and clojure-lsp help gets pretty limited). WDYT, @julienvincent @bpringe @ericdallo?

@julienvincent
Copy link
Contributor Author

I also expect it would be pretty uncommon. As a fallback users can always explicitly start the clojure-lsp server in the root if they want as well.

@julienvincent
Copy link
Contributor Author

@PEZ Are we concerned about this/anything else? Anything outstanding before this can be ready for merge?

src/project-root.ts Outdated Show resolved Hide resolved
Copy link
Member

@bpringe bpringe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left a suggestion and question.

The changes look good to me overall, though I haven't tested them. If @PEZ thinks it's good to go when he has a chance to look/test, then let's merge 🚀.

Thanks for the fixes!

@PEZ
Copy link
Collaborator

PEZ commented Feb 1, 2023

I think this is good to go. Will merge in a jiffy. Thanks again. I love working with you, @julienvincent!

A thing we can follow up with in a PR is to add a reason to the pre-selected project. In the jack-in/connect project menu, it is pulled out of, and breaks, the sort order. For good reasons, but the user isn't told those.

image

In the screenshot the user is told a ”reason” for the first entry, it's the Workspace root. The selected item could say something like Closest Project. Yeah, that's the reason why it is pre-selected, not why it is sorted where it is, but anyway.

I like that the workspace root is sorted to the top, btw. It makes sense and chimes with the rest of the ordering.

@PEZ PEZ merged commit 50f677b into BetterThanTomorrow:dev Feb 1, 2023
@julienvincent julienvincent deleted the fix/lsp-regressions branch February 2, 2023 03:49
julienvincent added a commit to julienvincent/calva that referenced this pull request Feb 2, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants