Language Server for Java using the Java compiler API
A Java language server based on v3.0 of the protocol and implemented using the Java compiler API.
Installation (VS Code)
Installation (other editors)
Vim (with vim-lsc)
Note: This tool is not compatible with vim-lsp as it only supports LSPv2.0.
Autocomplete symbols (with auto-import)
Type information on hover
The language server will provide autocomplete and other features using:
If the language server doesn't detect your external dependencies automatically, you can specify them using .vscode/settings.json
If all else fails, you can specify the java class path manually:
You can generate a list of external dependencies using your build tool:
The Java language server will look for the dependencies you specify in
The Java language server uses the Java compiler API to implement language features like linting, autocomplete, and smart navigation, and the language server protocol to communicate with text editors like VSCode.
The Java compiler API provides incremental compilation at the level of files: you can create a long-lived instance of the Java compiler, and as the user edits, you only need to recompile files that have changed. The Java language server optimizes this further by focusing compilation on the region of interest by erasing irrelevant code. For example, suppose we want to provide autocomplete after
None of the code inside
For most requests, the vast majority of code can be erased, dramatically speeding up compilation.
The java service process will output a log file to stderr, which is visible in VSCode using View / Output, under "Java".
If you have npm and maven installed, you should be able to install locally using
At the time of this writing, the build only works on Mac, because of the way it uses JLink. However, it would be straightforward to fix this by changing
Please run ./configure before your first commit to install a pre-commit hook that formats the code.