diff options
Diffstat (limited to '')
-rw-r--r-- | lua/conf/plugins/jdtls.lua | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/lua/conf/plugins/jdtls.lua b/lua/conf/plugins/jdtls.lua index b6dbd72..463fb23 100644 --- a/lua/conf/plugins/jdtls.lua +++ b/lua/conf/plugins/jdtls.lua @@ -1,64 +1,64 @@ -local misc = require('core.misc') -local lsp = require('core.lsp.functions') +local misc = require("core.misc") +local lsp = require("core.lsp.functions") local map, auto = misc.map, misc.auto -return { 'mfussenegger/nvim-jdtls', +return { "mfussenegger/nvim-jdtls", disable = not vim.fn.has("nvim-0.6.0"), - requires = 'mfussenegger/nvim-dap', + requires = "mfussenegger/nvim-dap", function() auto("FileType", { pattern = "java", callback = function() - local jdtls = require('jdtls') - local jdtls_install = require('mason-registry').get_package('jdtls'):get_install_path() + local jdtls = require("jdtls") + local jdtls_install = require("mason-registry").get_package("jdtls"):get_install_path() -- make sure to check if things with 💀 need updating local config = { cmd = { - 'java', -- 💀 - '-jar', vim.fn.glob(jdtls_install..'/plugins/org.eclipse.equinox.launcher_*.jar'), -- 💀 - '-configuration', jdtls_install..'/config_linux', - '-data', vim.fn.stdpath('cache')..'/nvim-jdtls', + "/usr/lib/jvm/openjdk21/bin/java", -- 💀 + "-jar", vim.fn.glob(jdtls_install.."/plugins/org.eclipse.equinox.launcher_*.jar"), -- 💀 + "-configuration", jdtls_install.."/config_linux", + "-data", vim.fn.stdpath("cache").."/nvim-jdtls", - '--add-modules=ALL-SYSTEM', - '--add-opens', 'java.base/java.lang=ALL-UNNAMED', - '--add-opens', 'java.base/java.util=ALL-UNNAMED', - '-Declipse.application=org.eclipse.jdt.ls.core.id1', - '-Declipse.product=org.eclipse.jdt.ls.core.product', - '-Dlog.level=ALL', - '-Dlog.protocol=true', - '-Dosgi.bundles.defaultStartLevel=4', - '-Xmx1G', + "--add-modules=ALL-SYSTEM", + "--add-opens", "java.base/java.lang=ALL-UNNAMED", + "--add-opens", "java.base/java.util=ALL-UNNAMED", + "-Declipse.application=org.eclipse.jdt.ls.core.id1", + "-Declipse.product=org.eclipse.jdt.ls.core.product", + "-Dlog.level=ALL", + "-Dlog.protocol=true", + "-Dosgi.bundles.defaultStartLevel=4", + "-Xmx1G", }, root_dir = vim.fs.dirname(vim.fs.find({ - 'gradlew', - '.git', - 'mvnw', - 'settings.gradle', -- Gradle (multi-project) - 'settings.gradle.kts', -- Gradle (multi-project) - 'build.xml', -- Ant - 'pom.xml', -- Maven + "gradlew", + ".git", + "mvnw", + "settings.gradle", -- Gradle (multi-project) + "settings.gradle.kts", -- Gradle (multi-project) + "build.xml", -- Ant + "pom.xml", -- Maven }, { upward = true })[1]), - -- don't print out status messages + -- don"t print out status messages handlers = { - ['language/status'] = function() end + ["language/status"] = function() end }, on_attach = function(_, bufnr) -- add some jdtls specific mappings local opts = { buffer = bufnr } - map('n', 'cri', jdtls.organize_imports, opts) - map('n', 'crv', jdtls.extract_variable, opts) - map('n', 'crc', jdtls.extract_constant, opts) - map('x', 'crv', function() jdtls.extract_variable(true) end, opts) - map('x', 'crc', function() jdtls.extract_constant(true) end, opts) - map('x', 'crm', function() jdtls.extract_method(true) end, opts) + map("n", "cri", jdtls.organize_imports, opts) + map("n", "crv", jdtls.extract_variable, opts) + map("n", "crc", jdtls.extract_constant, opts) + map("x", "crv", function() jdtls.extract_variable(true) end, opts) + map("x", "crc", function() jdtls.extract_constant(true) end, opts) + map("x", "crm", function() jdtls.extract_method(true) end, opts) pcall(vim.lsp.codelens.refresh) - auto('BufWritePost', { + auto("BufWritePost", { buffer = bufnr, - desc = 'refresh codelens', + desc = "refresh codelens", callback = function() pcall(vim.lsp.codelens.refresh) end @@ -88,7 +88,7 @@ return { 'mfussenegger/nvim-jdtls', end -- compile our code - vim.system({ 'javac', src_path, '-d', vim.fn.stdpath("cache") }, {}, function(out) + vim.system({ "javac", src_path, "-d", vim.fn.stdpath("cache") }, {}, function(out) if out.code ~= 0 then cache_path = nil end @@ -98,7 +98,7 @@ return { 'mfussenegger/nvim-jdtls', -- check if we have a compiled version of JavaVersion local f, _ = io.open(cache_path, "r") - if not f then -- if we don't have a cache + if not f then -- if we don"t have a cache build_cache() else io.close(f) @@ -118,12 +118,15 @@ return { 'mfussenegger/nvim-jdtls', on_exit = function(_, exit_code, _) local v = vim.version.parse(table.concat(buffer)) - -- if there's an error, no version info, or the java version is + -- if there"s an error, no version info, or the java version is -- less than 17 stop the lsp from starting if exit_code ~= 0 then vim.notify(string.format( "java version check failed: exit code %s", exit_code), vim.log.levels.ERROR, { title = misc.appid }) + vim.notify(string.format( + "%s", vim.inspect(buffer)), + vim.log.levels.ERROR, { title = misc.appid }) return elseif not v then vim.notify("no java version info found", vim.log.levels.ERROR, |