From f9793c25a6a59c131903c81b1ca25fe2ab15b54a Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Thu, 3 Apr 2025 06:27:42 -0400 Subject: [PATCH] fix(lsp-java): point `jdtls` to proper directory locations Apparently, the per-project directory system I was using isn't supported by the language server... even though there is absolutely no documentation specifying that. --- config.org | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/config.org b/config.org index 6f251d9..5f8589a 100644 --- a/config.org +++ b/config.org @@ -4219,15 +4219,26 @@ The =lsp-java= package provides LSP support using the standard Java language ser (setq lsp-java-jdt-ls-prefer-native-command t)) (add-hook! java-mode (setq-local lsp-java-server-install-dir - (concat (+lsp-java-server-store-path) "/share/java/jdtls/"))) + (f-slash (+lsp-java-server-store-path)))) -(defadvice! ~/lsp-java-ls-command () - "Configure `lsp-java' to work with Nix." - :override #'lsp-java--ls-command - (let ((root (or (doom-project-root) (f-join (getenv "XDG_DATA_HOME") "jdtls")))) - (list lsp-java-jdt-ls-command - "-configuration" (f-join root "config-linux") - "-data" (f-join root "java-workspace")))) +;; The relative locations of the binary and jar file are different +;; on NixOS than on most other Linux distros + +(defadvice! ~/lsp-java-locate-server-jar (old-fn) + :around #'lsp-java--locate-server-jar + (let ((lsp-java-server-install-dir + (concat lsp-java-server-install-dir "share/java/jdtls/"))) + (funcall old-fn))) +#+end_src + +*** Project File Conflict + +Doom's standard library allows for an empty =.project= file to mark the root of a project directory. This is a decent idea, but unfortunately Gradle's project structure contains a file of that name that isn't necessarily at the root, and so this must be disabled to prevent Doom from breaking those projects. + +#+begin_src emacs-lisp +(after! projectile + (setq projectile-project-root-files-bottom-up + (delete ".project" projectile-project-root-files-bottom-up))) #+end_src ** Language Servers