@@ -46,6 +46,16 @@ The slash is expected at the end."
46
46
:risky t
47
47
:type 'directory )
48
48
49
+ (defcustom lsp-java-jdt-ls-prefer-native-command nil
50
+ " Use native jdtls command provided by jdtls installation instead of lsp's java -jar invocation."
51
+ :risky t
52
+ :type 'boolean )
53
+
54
+ (defcustom lsp-java-jdt-ls-command " jdtls"
55
+ " Native jdtls command provided by jdtls installation."
56
+ :risky t
57
+ :type 'string )
58
+
49
59
(defcustom lsp-java-jdt-download-url " https://www.eclipse.org/downloads/download.php?file=/jdtls/milestones/1.23.0/jdt-language-server-1.23.0-202304271346.tar.gz"
50
60
" JDT JS download url.
51
61
Use https://download.eclipse.org/jdtls/milestones/1.12.0/jdt-language-server-1.12.0-202206011637.tar.gz if you want to use older java version."
@@ -551,6 +561,13 @@ The entry point of the language server is in `lsp-java-server-install-dir'/plugi
551
561
(server-jar-filenames
552
562
(error " Unable to find single point of entry %s " server-jar-filenames))))
553
563
564
+ (defun lsp-java--locate-server-command ()
565
+ " Return the jdtls command location of the language server.
566
+
567
+ The entry point of the language server is in `lsp-java-server-install-dir' /bin/jdtls[.bat]."
568
+ (let ((bin-path (expand-file-name " bin" lsp-java-server-install-dir)))
569
+ (locate-file lsp-java-jdt-ls-command `(, bin-path ) exec-suffixes 1 )))
570
+
554
571
(defun lsp-java--locate-server-config ()
555
572
" Return the server config based on OS."
556
573
(let ((config (cond
@@ -652,27 +669,34 @@ FULL specify whether full or incremental build will be performed."
652
669
653
670
(defun lsp-java--ls-command ()
654
671
" LS startup command."
655
- (let ((server-jar (lsp-file-local-name (lsp-java--locate-server-jar)))
656
- (server-config (if lsp-java-server-config-dir
657
- lsp-java-server-config-dir
658
- (lsp-file-local-name (lsp-java--locate-server-config))))
659
- (java-9-args (when (lsp-java--java-9-plus-p)
660
- lsp-java-9-args)))
661
- (lsp-java--ensure-dir lsp-java-workspace-dir)
662
- `(, lsp-java-java-path
663
- " -Declipse.application=org.eclipse.jdt.ls.core.id1"
664
- " -Dosgi.bundles.defaultStartLevel=4"
665
- " -Declipse.product=org.eclipse.jdt.ls.core.product"
666
- " -Dlog.protocol=true"
667
- " -Dlog.level=ALL"
668
- ,@lsp-java-vmargs
669
- " -jar"
670
- , server-jar
671
- " -configuration"
672
- , server-config
673
- " -data"
674
- ,(lsp-file-local-name lsp-java-workspace-dir)
675
- ,@java-9-args )))
672
+ (let ((server-cmd (lsp-java--locate-server-command)))
673
+ (if (and lsp-java-jdt-ls-prefer-native-command
674
+ server-cmd)
675
+ `(, server-cmd
676
+ " --jvm-arg=-Dlog.protocol=true"
677
+ " --jvm-arg=-Dlog.level=ALL"
678
+ ,@(mapcar (lambda (str ) (concat " --jvm-arg=" str)) lsp-java-vmargs))
679
+ (let ((server-jar (lsp-file-local-name (lsp-java--locate-server-jar)))
680
+ (server-config (if lsp-java-server-config-dir
681
+ lsp-java-server-config-dir
682
+ (lsp-file-local-name (lsp-java--locate-server-config))))
683
+ (java-9-args (when (lsp-java--java-9-plus-p)
684
+ lsp-java-9-args)))
685
+ (lsp-java--ensure-dir lsp-java-workspace-dir)
686
+ `(, lsp-java-java-path
687
+ " -Declipse.application=org.eclipse.jdt.ls.core.id1"
688
+ " -Dosgi.bundles.defaultStartLevel=4"
689
+ " -Declipse.product=org.eclipse.jdt.ls.core.product"
690
+ " -Dlog.protocol=true"
691
+ " -Dlog.level=ALL"
692
+ ,@lsp-java-vmargs
693
+ " -jar"
694
+ , server-jar
695
+ " -configuration"
696
+ , server-config
697
+ " -data"
698
+ ,(lsp-file-local-name lsp-java-workspace-dir)
699
+ ,@java-9-args )))))
676
700
677
701
(eval-and-compile
678
702
(lsp-interface
0 commit comments