Created
May 23, 2022 19:36
-
-
Save jahkeup/941a2741a83fec8b62632b822d49080d to your computer and use it in GitHub Desktop.
Snippet to configure JDT-LS for use with tools like Lombok
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(after! lsp-java | |
(setq! lsp-java-vmargs | |
;; Provide access to internals for compiler related tooling (such as | |
;; LSP introspective servers or annotation preprocessors - like | |
;; Lombok). | |
(apply #'append lsp-java-vmargs (mapcar (lambda (pkg) (list "--add-exports" | |
(format "%s=ALL-UNNAMED" pkg))) | |
'("jdk.compiler/com.sun.tools.javac.code" | |
"jdk.compiler/com.sun.tools.javac.util" | |
"jdk.compiler/com.sun.tools.javac.api" | |
"jdk.compiler/com.sun.tools.javac.tree" | |
"jdk.compiler/com.sun.tools.javac.resources" | |
"java.management/sun.management")))) | |
(add-hook! java-mode | |
(when-let ((lombok-jar (getenv "LOMBOK_JAR"))) | |
(when (file-exists-p lombok-jar) | |
(message "adding Lombok to JVM classpath (%s)" lombok-jar) | |
(setq-local lsp-java-vmargs | |
(append (list (format "-Xbootclasspath/a:%s" lombok-jar) | |
(format "-javaagent:%s" lombok-jar)) | |
lsp-java-vmargs))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment