yveszoundi / eglot-java

Java extension for the eglot LSP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use jdtls startup script by default?

yveszoundi opened this issue · comments

Background

By default, eglot-java doesn't use the Eclipse JDT LS startup scripts (jdtls binary).

  • This package was created before jdtls startup scripts existed (See eclipse-jdtls/eclipse.jdt.ls#1823)
  • The jdtls startup scripts require a Python installation
    • On Linux, Python is typically pre-installed on Linux, as many programs use that
    • On Windows, Python is not pre-installed
    • On Mac OS, Python is also not bundled anymore as of MacOS Monterey 12.3

Problem

By default, eglot-java dynamically modifies the eglot-server-programs variable for launching the Eclipse JDT LS server.
Some users might not realize that, even though it's documented (Package headers and GitHub project README), and that will result into both frustration and time wasted.

Scenario 1 - eglot changes how LSP servers can be mapped to programming modes

  • Evidence: #8
  • Problem: eglot won't be able to start the LSP server, with obscure error emacs-lisp messages

Scenario 2 - users have already configured eglot-server-programs to their liking for jdtls

Request

Changes

There's an existing variable that controls how eglot-java dynamically modifies the value of eglot-server-programs.

eglot-java-eglot-server-programs-manual-updates is a variable defined in ‘eglot-java.el’.

Its value is nil

Do not try to automatically update eglot-server-programs

The change will change the default value of eglot-java-eglot-server-programs-manual-updates to t. The project documentation will also need to be updated to reflect that

Expected Impacts

  • Potentially negligible for the vast majority of new users.
    • People typically installed eglot-java when they do not want an involved configuration
    • By that time, they might already have an awareness of jdtls startup scripts and mostly value eglot-java for its ability to automatically install the Eclipse JDT LS server.
  • Potentially annoying for existing users, as it may break their existing customization
    • Any custom JVM arguments would be ignored when switching to the jdtls script
    • Windows or Mac OS users don't necessarily have Python installed and they might not be aware that the jdtls script needs it...

Caveats

I don't feel that eglot java defaults are that good myself: see joaotavora/eglot#1008 (comment). Either way, it's probably better to have an explicit user opt-in (eglot-java magic), instead of people continuously running into configuration issues...

I'll leave this open, as I don't know what's the best course of action for most users.

This wouldn't be such a good decision after practical experimentation.

Python dependency

Some people might not know that jdtls scripts require Python 3.9+:

  • On Mac OS and Windows, many users might not have Python installed.
    • Many proably don't read carefully installation instructions
    • When "it doesn't work", they'll just open a bug here, instead of checking out the Eclipse JDT LS project
  • Some people might have an old version of Python installed ("Why didn't you tell me to upgrade Python??")

eglot-java initialization changes

Need to add the bin folder of LSP server installation folder to the emacs exec-path.

  • This is not a big deal, coding wise
  • If the jdtls/bin folder is not in the PATH variale, eglot-java will attempt to auto-install the LSP server.
    • Some users might not understand what's going on...
    • They'll hopefully discover that they need configure eglot-java-server-install-dir

LSP server initialization options

Users would need to configure themselves basic options (disabling or not gradle, etc.): See eglot/discussions/1222.

  • On one end, all that logic could be removed from eglot-java
  • On the other end, people who mostly copy-paste elisp snippets might not be comfortable.