Friday, 12 March 2021

Manual LSP Java setup for Emacs 27.1

How can I set up LSP mode manually for Java in Emacs?

  1. Install lsp-mode and lsp-java in Emacs.
  2. Install flycheck (lsp-java doesn't seem to work with the built-in flymake in Emacs 27.1).
  3. Download Eclipse JDT Language Server from https://projects.eclipse.org/projects/eclipse.jdt.ls, Downloads > Milestones builds > 0.70 > jdt-language-server-0.70.0-202103051608.tar.gz
  4. Set Emacs variable lsp-java-server-install-dir to extracted folder.
  5. Download Java Debug Server for Visual Studio Code and build it using mvn https://github.com/microsoft/java-debug
  6. Copy com.microsoft.java.debug.plugin-0.30.0.jar from java-debug\com.microsoft.java.debug.plugin\target\ to jdt-language-server-0.70.0-202103051608\bundles\
  7. (add-hook 'java-mode-hook #'lsp)

Note: lsp-java does support an automatic installation option; it's always interesting to see what goes on under the hood!

No comments:

Post a Comment