[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Editing Java (with LSP)

From: Filipp Gunbin
Subject: Re: Editing Java (with LSP)
Date: Mon, 13 Jun 2022 18:48:12 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)


On 13/06/2022 15:43 +0200, Alessandro Bertulli wrote:

> Hi all!
> I am struggling to instruct Emacs to properly assist me in writing Java
> code. Whereas using C/C++ was a breeze, Java simply seems to be more
> buggy. I explain: using the integrated server from lsp-mode seems to be
> broken. I partially resolved it by manually dowloading a (much) newer
> version of the server (which is jdtls). This seemed to solve part of the
> problems, but the experience is still buggy. Completion often is not
> triggered (not even by explicitly C-M-i), the server sometimes crashes,
> and when I modify the buffer I need to write it before error
> highlighting properly updates (for instance, if I modify a piece of code
> who had an error, that point on screen is still highlightd as an error,
> even if it's now in the middle of a word). Moreover, the indentation
> sometimes doesn't work.
> Now, it seems like:
> - I am one of the very, very few people on Earth using Emacs to write
> Java

That seems to be true.  There're very few of us.

> - I am the only one having problems.
> Can you please give me your feedback? Does any of you write Java code?
> How is it? Do you have the same problems too? If yes, have you found a
> solution? Do you use LSP? Or some other package?
> Note that my config is simply lsp-mode + lsp-java.

I use my package javaimp (,
it's limited in functionality, but it fits my needs.

Current version knows about the project structure and dependencies (from
Maven or Gradle), assists with completion in imports, and implements
imenu better than cc-mode.  Next version is almost ready, it has
improved parsing (for imenu and other stuff), limited xref support
(finding a definition should work), navigation functions, and a minor
mode to enable all that.

Next, I plan to add support for debugging via gud (I already have the
dependencies info), REPL via jshell (jdk 11), and perhaps implement
indentation (this will remove dependency on cc-mode).  However, I don't
know when I'll be able to complete all this.

I don't intend to work on good font-lock support, because I don't use it
myself, and it would require full source parsing, which is better done
with treesitter (there's ongoing work on treesitter integration into
Emacs, hopefully we'll see it soon).  Also, clever source completion is
also not in my plan: for that, you need a compiler, via lsp or directly.

HTH, Filipp

reply via email to

[Prev in Thread] Current Thread [Next in Thread]