From 60bd6e4b8e998f0f98c54f7a1a92c64f9af10d89 Mon Sep 17 00:00:00 2001 From: coderkun Date: Tue, 15 Oct 2024 11:03:18 +0200 Subject: [PATCH] nvim: Move JDTLS config to ftplugin for Java --- nvim/ftplugin/java.lua | 52 +++++++++++++++++++++++++++++++++++ nvim/lua/plugins/jdtls.lua | 55 -------------------------------------- 2 files changed, 52 insertions(+), 55 deletions(-) diff --git a/nvim/ftplugin/java.lua b/nvim/ftplugin/java.lua index 2ddf1f1..6243d58 100644 --- a/nvim/ftplugin/java.lua +++ b/nvim/ftplugin/java.lua @@ -2,3 +2,55 @@ vim.opt.spell = true vim.opt.spelllang = "en_us" vim.opt.colorcolumn = "120" vim.opt.textwidth = 120 + +require('jdtls').start_or_attach({ + cmd = {'jdtls'}, + 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', 'mvnw'}, { upward = true })[1]), + init_options = { + bundles = { + vim.fn.expand("$MASON/share/java-debug-adapter/com.microsoft.java.debug.core.jar"), + vim.fn.expand("$MASON/share/java-debug-adapter/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 = false, + description = { + enabled = false + }, + }, + format = { + enable = true, + settings = { + url = "/home/oliver/Dokumente/Gallery Systems/Products/GS Eclipse Formatter Java.xml" + }, + }, + }, + }, +}) diff --git a/nvim/lua/plugins/jdtls.lua b/nvim/lua/plugins/jdtls.lua index 9b0b64f..4d2bcbb 100644 --- a/nvim/lua/plugins/jdtls.lua +++ b/nvim/lua/plugins/jdtls.lua @@ -3,60 +3,7 @@ return { dependencies = { "williamboman/mason.nvim" }, - ft = "java", config = function() - local jdtlsConfig = { - cmd = {'jdtls'}, - 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', 'mvnw'}, { upward = true })[1]), - init_options = { - bundles = { - vim.fn.expand("$MASON/share/java-debug-adapter/com.microsoft.java.debug.core.jar"), - vim.fn.expand("$MASON/share/java-debug-adapter/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 = false, - description = { - enabled = false - }, - }, - format = { - enable = true, - settings = { - url = "/home/oliver/Dokumente/Gallery Systems/Products/GS Eclipse Formatter Java.xml" - }, - }, - }, - }, - } - local dap = require('dap') dap.configurations.java = {{ type = 'java', @@ -77,7 +24,5 @@ return { hostName = '127.0.0.1', port = 5105, }} - - require('jdtls').start_or_attach(jdtlsConfig) end, }