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

[lsp-magik] Support JAVA_HOME with trailing slash #4139

Merged
merged 1 commit into from
Aug 22, 2023
Merged

[lsp-magik] Support JAVA_HOME with trailing slash #4139

merged 1 commit into from
Aug 22, 2023

Conversation

sebastiaanspeck
Copy link
Contributor

@sebastiaanspeck sebastiaanspeck commented Aug 17, 2023

If $JAVA_HOME ends with a "/", which is the case when using OpenJDK e.a, the current code doesn't work. It would set it to bin/java. Using the new code, we add bin/java to the result of $JAVA_HOME. To work for a $JAVA_HOME that doesn't end with a "/", we use (expand-file-name..., which adds a "/", but only if needed.

@github-actions github-actions bot added the client One or more of lsp-mode language clients label Aug 17, 2023
@sebastiaanspeck sebastiaanspeck marked this pull request as draft August 18, 2023 07:08
@sebastiaanspeck sebastiaanspeck marked this pull request as ready for review August 18, 2023 07:20
@sebastiaanspeck
Copy link
Contributor Author

Can this PR please get a review?

@@ -88,7 +88,8 @@
:group `lsp-magik
:package-version '(lsp-mode . "8.0.1"))

(defcustom lsp-magik-java-path (cond ((eq system-type 'windows-nt) "$JAVA_HOME/bin/java")
(defcustom lsp-magik-java-path (cond ((eq system-type 'windows-nt) (or (executable-find (expand-file-name "bin/java" (getenv "JAVA_HOME")))
Copy link
Member

Choose a reason for hiding this comment

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

I dont like this to be executed on load time. Imagine every package to perform that on startup similar logic - it will kill lsp-mode's load time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would you suggest?

Copy link
Member

Choose a reason for hiding this comment

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

Use lambda and then lsp-resolve-value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this?:

(defcustom lsp-magik-java-path (cond ((eq system-type 'windows-nt)
                                      (lambda ()
                                        (or (lsp-resolve-value (executable-find (expand-file-name "bin/java" (getenv "JAVA_HOME"))))
                                            (lsp-resolve-value (executable-find "java")))))
                                     (t "java"))
  "Path of the java executable."
  :type 'string
  :group `lsp-magik
  :package-version '(lsp-mode . "8.0.1"))

Copy link
Member

Choose a reason for hiding this comment

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

to me, it looks like it will be better to wrap the whole thing in a lambda

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please review the latest update

@yyoncho yyoncho merged commit 72649c7 into emacs-lsp:master Aug 22, 2023
13 of 14 checks passed
@yyoncho
Copy link
Member

yyoncho commented Aug 22, 2023

Thank you!

@sebastiaanspeck sebastiaanspeck deleted the fix/support-JAVA_HOME-with-trailing-slash branch August 22, 2023 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client One or more of lsp-mode language clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants