Finish wiring up nvim-java (jdtls bootstrap)

nvim-java was installed but never initialized, so jdtls ran vanilla and the
plugin's value-add (tests, DAP, refactors, Spring Boot) was inert. Wire it up
following the current nvim-java README (Neovim 0.11.5+ / vim.pack install):

- lua/custom/plugins/nvim-java.lua now installs the full stack (spring-boot.nvim
  pinned, nui.nvim, nvim-dap, nvim-java), calls `require('java').setup()` and
  then `vim.lsp.enable('jdtls')`, in that required order.
- init.lua: the LSP config/enable loop now SKIPS jdtls, so nvim-java is the
  single owner of jdtls configuration and enablement. This avoids a second,
  competing vanilla jdtls setup while jdtls stays in the `servers` table purely
  so mason-tool-installer keeps it installed.
- java-debug-adapter + java-test remain provided via mason-nvim-dap (debug.lua),
  giving nvim-java the bundles it launches jdtls with for DAP and tests.

Verified headless: opening a .java buffer attaches exactly one jdtls client
(plus spring-boot), with no duplicate/competing jdtls setup and no Lua errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
HuNtErJ1324 2026-06-21 15:17:23 -07:00
parent dbbcf92be8
commit 4f0c0471cd
2 changed files with 39 additions and 8 deletions

View File

@ -706,7 +706,11 @@ do
stylua = {}, -- Used to format Lua code stylua = {}, -- Used to format Lua code
-- Java language server (installed via Mason). -- Java: jdtls is installed via Mason (it's a key here so mason-tool-installer
-- picks it up), but its LSP config and `vim.lsp.enable` are owned by nvim-java
-- (see lua/custom/plugins/nvim-java.lua). We therefore SKIP jdtls in the
-- config/enable loop below so nvim-java's jdtls bootstrap is the one that wins
-- and there is no competing vanilla jdtls setup.
jdtls = {}, jdtls = {},
-- ty: Astral's Python type checker. Not yet shipped by nvim-lspconfig, so we -- ty: Astral's Python type checker. Not yet shipped by nvim-lspconfig, so we
@ -797,8 +801,13 @@ do
require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-tool-installer').setup { ensure_installed = ensure_installed }
for name, server in pairs(servers) do for name, server in pairs(servers) do
vim.lsp.config(name, server) -- jdtls is configured and enabled by nvim-java (lua/custom/plugins/nvim-java.lua),
vim.lsp.enable(name) -- which must run `require('java').setup()` before `vim.lsp.enable('jdtls')`.
-- Skip it here to avoid a second, competing jdtls setup.
if name ~= 'jdtls' then
vim.lsp.config(name, server)
vim.lsp.enable(name)
end
end end
end end

View File

@ -1,7 +1,29 @@
-- nvim-java: Java IDE layer on top of jdtls. -- nvim-java: full Java IDE layer on top of jdtls (tests, DAP, refactors, Spring Boot).
-- https://github.com/nvim-java/nvim-java -- https://github.com/nvim-java/nvim-java
-- --
-- NOTE: This only installs the plugin (mirroring the user's original -- This file is loaded by the custom-plugins loader (lua/custom/plugins/init.lua),
-- `return { 'nvim-java/nvim-java' }` spec). It is NOT yet initialized, so jdtls -- which runs in Section 10 of init.lua -- AFTER the LSP section (Section 6). The LSP
-- currently runs vanilla. Wiring (`require('java').setup()`) is finished later. -- section deliberately SKIPS jdtls in its `vim.lsp.config`/`vim.lsp.enable` loop, so
vim.pack.add { 'https://github.com/nvim-java/nvim-java' } -- this is the single place jdtls is configured and enabled. That guarantees the
-- required order (`require('java').setup()` before `vim.lsp.enable('jdtls')`) and
-- avoids a second, competing vanilla jdtls setup.
--
-- Requirements (nvim-java README, vim.pack install): Neovim 0.11.5+. jdtls,
-- java-debug-adapter and java-test are provided via Mason -- jdtls from the LSP
-- section's mason-tool-installer, java-debug-adapter + java-test from
-- lua/kickstart/plugins/debug.lua (mason-nvim-dap). nvim-dap and nui.nvim are also
-- pulled in by debug.lua / neo-tree.lua respectively; re-listing them here is
-- idempotent and keeps this spec self-contained per the README.
vim.pack.add {
{ src = 'https://github.com/JavaHello/spring-boot.nvim', version = '218c0c26c14d99feca778e4d13f5ec3e8b1b60f0' },
'https://github.com/MunifTanjim/nui.nvim',
'https://github.com/mfussenegger/nvim-dap',
'https://github.com/nvim-java/nvim-java',
}
-- Must run BEFORE jdtls is enabled: it patches the jdtls config so the language
-- server is launched with the java-test / java-debug-adapter bundles.
require('java').setup()
-- Enable jdtls using the config nvim-java just registered (the new Neovim 0.11+ API).
vim.lsp.enable 'jdtls'