No need to put up with jdtls nonsense anymore.
Just install and start writing public static void main(String[] args).
Warning
This is a WIP but we are so close to v1.0.0. So it could be rough around the edges and documents might not be up to date. You can check the progress we are making here https://github.com/orgs/nvim-java/projects/1/views/2.
- ✅ Diagnostics & Auto Completion
- ✅ Automatic DAP debug configuration
- ✅ Running tests
- Uses nvim-lspconfig to setup
jdtls - Realtime server settings updates is possible using neoconf
- Everything necessary will be installed automatically
- Uses
jdtlsand auto loadsjdtlsplugins from mason.nvim- Supported plugins are,
lombokjava-testjava-debug-adapter
- Supported plugins are,
- Typed & documented APIs
📌 details
-
Pre-requisites
- Python 3.9 - for running
jdtlswrapper launch script
- Python 3.9 - for running
-
Install the plugin
Using lazy.nvim
return {
'nvim-java/nvim-java',
dependencies = {
'nvim-java/lua-async-await',
'nvim-java/nvim-java-core',
'nvim-java/nvim-java-test',
'MunifTanjim/nui.nvim',
'neovim/nvim-lspconfig',
'mfussenegger/nvim-dap',
{
'williamboman/mason.nvim',
opts = {
registries = {
'github:nvim-java/nvim-java-mason-registry',
'github:mason-org/mason-registry',
},
},
}
},
event = 'VeryLazy',
opts = {},
}-
Make sure to run
MasonUpdate -
Setup jdtls like you would usually do
require('lspconfig').jdtls.setup({})Yep! That's all :)
📌 details
JavaDapConfig- DAP is autoconfigured on start up, but in case you want to force configure it again, you can use this APIJavaTestRunCurrentClass- Run the test class in the active bufferJavaTestDebugCurrentClass- Debug the test class in the active bufferJavaTestRunCurrentMethod- Run the test method on the cursorJavaTestDebugCurrentMethod- Debug the test method on the cursorJavaTestViewLastReport- Open the last test report in a popup window
📌 details
DAP
config_dap- DAP is autoconfigured on start up, but in case you want to force configure it again, you can use this API
require('java').dap.config_dap()Test
run_current_class- Run the test class in the active buffer
require('java').test.run_current_class()debug_current_class- Debug the test class in the active buffer
require('java').test.debug_current_class()run_current_method- Run the test method on the cursor
require('java').test.run_current_method()debug_current_method- Debug the test method on the cursor
require('java').test.debug_current_method()view_report- Open the last test report in a popup window
require('java').test.view_last_report()nvim-jdtls is a plugin that follows "Keep it simple, stupid!" approach. If you love customizing things by yourself, then give nvim-jdtls a try. I may or may not have copied some code 😉 Beauty of Open source!