Skip to content

Instantly share code, notes, and snippets.

@jay-babu
Created December 10, 2022 00:23
Show Gist options
  • Save jay-babu/8ed5726f6795e06f5b1ba4934d5a66c8 to your computer and use it in GitHub Desktop.
Save jay-babu/8ed5726f6795e06f5b1ba4934d5a66c8 to your computer and use it in GitHub Desktop.
diff --git a/shell/.config/nvim/lua/user/lsp/on_attach.lua b/shell/.config/nvim/lua/user/lsp/on_attach.lua
index 256cae8..646103a 100644
--- a/shell/.config/nvim/lua/user/lsp/on_attach.lua
+++ b/shell/.config/nvim/lua/user/lsp/on_attach.lua
@@ -5,4 +5,14 @@ return function(client, bufnr)
inlayhints.on_attach(client, bufnr)
end
end
+
+ if client.name == "jdtls" then
+ -- With `hotcodereplace = 'auto' the debug adapter will try to apply code changes
+ -- you make during a debug session immediately.
+
+ -- Remove the option if you do not want that.
+ -- You can use the `JdtHotcodeReplace` command to trigger it manually
+ require("jdtls").setup_dap({ hotcodereplace = "auto" })
+ require("jdtls.dap").setup_dap_main_class_configs()
+ end
end
diff --git a/shell/.config/nvim/lua/user/lsp/server-settings/jdtls.lua b/shell/.config/nvim/lua/user/lsp/server-settings/jdtls.lua
index 7de0907..ec18b6e 100644
--- a/shell/.config/nvim/lua/user/lsp/server-settings/jdtls.lua
+++ b/shell/.config/nvim/lua/user/lsp/server-settings/jdtls.lua
@@ -23,6 +23,24 @@ return function()
local install_path = require("mason-registry").get_package("jdtls"):get_install_path()
vim.list_extend(bundles, vim.split(vim.fn.glob(home .. "/.local/share/vscode-java-decompiler/server/*jar"), "\n"))
+ vim.list_extend(
+ bundles,
+ vim.fn.glob(
+ require("mason-registry").get_package("java-debug-adapter"):get_install_path()
+ .. "/extension/server/com.microsoft.java.debug.plugin-*.jar",
+ 1
+ )
+ )
+ vim.list_extend(
+ bundles,
+ vim.split(
+ vim.fn.glob(
+ require("mason-registry").get_package("java-test"):get_install_path() .. "/extension/server/*.jar",
+ 1
+ ),
+ "\n"
+ )
+ )
-- get the current OS
local operating_system
@@ -46,8 +64,8 @@ return function()
-- "-Xms1g",
-- "-javaagent:" .. install_path .. "/lombok.jar",
"--jvm-arg=-javaagent:"
- .. install_path
- .. "/lombok.jar",
+ .. install_path
+ .. "/lombok.jar",
-- "-jar",
-- vim.fn.glob(install_path .. "/plugins/org.eclipse.equinox.launcher_*.jar"),
"-configuration",
@@ -65,6 +83,7 @@ return function()
workspaceFolders = ws_folders_jdtls,
bundles = bundles,
},
+ on_attach = astronvim.lsp.on_attach,
settings = {
java = {
signatureHelp = {
@@ -104,12 +123,12 @@ return function()
completion = {
guessMethodArguments = true,
favoriteStaticMembers = {
- "org.hamcrest.MatcherAssert.assertThat",
- "org.hamcrest.Matchers.*",
- "org.hamcrest.CoreMatchers.*",
- "org.junit.jupiter.api.Assertions.*",
"java.util.Objects.requireNonNull",
"java.util.Objects.requireNonNullElse",
+ "org.assertj.core.api.Assertions.*",
+ "org.hamcrest.CoreMatchers.*",
+ "org.hamcrest.Matchers.*",
+ "org.junit.jupiter.api.Assertions.*",
"org.mockito.Mockito.*",
},
},
diff --git a/shell/.config/nvim/lua/user/plugins/mason-nvim-dap.lua b/shell/.config/nvim/lua/user/plugins/mason-nvim-dap.lua
index 1a19290..2a65089 100644
--- a/shell/.config/nvim/lua/user/plugins/mason-nvim-dap.lua
+++ b/shell/.config/nvim/lua/user/plugins/mason-nvim-dap.lua
@@ -1,4 +1,8 @@
return {
- automatic_installation = true,
- automatic_setup = true,
+ ensure_installed = {
+ "javadbg",
+ "javatest",
+ },
+ automatic_installation = true,
+ automatic_setup = true,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment