From c9102bc35185284ddce28eb216fd125fa0e0fa8b Mon Sep 17 00:00:00 2001 From: Michael Kwan Date: Tue, 26 Nov 2024 03:13:01 -0500 Subject: [PATCH] fix(java): give java a default nvim-dap config (#4261) ## Description Currently, there are no Java configurations for nvim-dap upon enabling the Java extras. This requires debugging configurations to be setup manually afterwards. (This is unlike many other language extras which do have nvim-dap support "out of the box") This pr creates an initial configuration for nvim-dap which lets it attach to a debugging process on port 5005. (such as a spring boot application) More can be added if there are any experienced Java devs here. ## Related Issue(s) None ## Screenshots Error message: ![image](https://github.com/user-attachments/assets/5922cf48-6ac7-4a2a-8785-1f9b958089e4) Java remote debugging open: ![image](https://github.com/user-attachments/assets/dfbe7c5b-2308-4aa4-a236-487605e4c75a) ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- lua/lazyvim/plugins/extras/lang/java.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 9be1ea9c..f4c07320 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -40,6 +40,20 @@ return { { "mfussenegger/nvim-dap", optional = true, + opts = function() + -- Simple configuration to attach to remote java debug process + -- Taken directly from https://github.com/mfussenegger/nvim-dap/wiki/Java + local dap = require("dap") + dap.configurations.java = { + { + type = "java", + request = "attach", + name = "Debug (Attach) - Remote", + hostName = "127.0.0.1", + port = 5005, + }, + } + end, dependencies = { { "williamboman/mason.nvim",