From 59e0bc692be0004b7326626b29a2e3a89c453735 Mon Sep 17 00:00:00 2001 From: Olli Date: Fri, 15 May 2026 15:07:52 +0200 Subject: [PATCH] nvim: Fix Java LSP configuration --- nvim/ftplugin/java.lua | 65 ------------------------------------------ nvim/lua/user/lsp.lua | 44 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 65 deletions(-) diff --git a/nvim/ftplugin/java.lua b/nvim/ftplugin/java.lua index 8e0fee1..2ddf1f1 100644 --- a/nvim/ftplugin/java.lua +++ b/nvim/ftplugin/java.lua @@ -2,68 +2,3 @@ vim.opt.spell = true vim.opt.spelllang = "en_us" vim.opt.colorcolumn = "120" vim.opt.textwidth = 120 - -require('jdtls').start_or_attach({ - cmd = { - 'jdtls', - '-parameters' - }, - on_attach = function(client, bufnr) - require('jdtls').setup_dap({hotcodereplace = 'auto'}) - require('jdtls.dap').setup_dap_main_class_configs() - end, - root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'gradle.properties'}, { upward = true })[1]), - init_options = { - bundles = { - vim.fn.expand("/usr/share/java-debug/com.microsoft.java.debug.core.jar"), - vim.fn.expand("/usr/share/java-debug/com.microsoft.java.debug.plugin.jar"), - }, - }, - java = { - autobuild = { - enabled = true - }, - debug = { - settings = { - hotCodeReplace = 'auto' - }, - }, - }, - settings = { - java = { - autobuild = { - enabled = true - }, - debug = { - settings = { - hotCodeReplace = 'auto' - }, - }, - saveActions = { - organizeImports = true - }, - signatureHelp = { - enabled = true, - description = { - enabled = true - }, - }, - format = { - enable = true, - settings = { - url = "/home/oliver/Dokumente/Gallery Systems/Products/GS Eclipse Formatter Java.xml" - }, - }, - codeGeneration = { - insertionLocation = 'lastMember', - hashCodeEquals = { - useInstanceof = true, - useJava7Objects = true, - }, - }, - telemetry = { - enabled = false, - }, - }, - }, -}) diff --git a/nvim/lua/user/lsp.lua b/nvim/lua/user/lsp.lua index 11aaf63..fffc3dd 100644 --- a/nvim/lua/user/lsp.lua +++ b/nvim/lua/user/lsp.lua @@ -75,3 +75,47 @@ vim.lsp.config('tsserver', { root_dir = vim.fs.root(0, {'.git', 'package.json'}), capabilities = capabilities, }) +-- Java +require("jdtls").setup_dap({ + hotcodereplace = "auto", +}) +vim.lsp.config("jdtls", { + init_options = { + bundles = { + vim.fn.glob("/usr/share/java-debug/*.jar", 1), + } + }, + settings = { + java = { + autobuild = { + enabled = true, + }, + saveActions = { + organizeImports = true, + }, + signatureHelp = { + enabled = true, + description = { + enabled = true, + }, + }, + format = { + enable = true, + settings = { + url = "/home/oliver/Dokumente/Gallery Systems/Products/GS Eclipse Formatter Java.xml", + }, + }, + codeGeneration = { + insertionLocation = 'lastMember', + hashCodeEquals = { + useInstanceof = true, + useJava7Objects = true, + }, + }, + telemetry = { + enabled = false, + }, + }, + }, +}) +vim.lsp.enable("jdtls")