mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 00:25:47 +02:00
enc: add alternative config jdtls
This commit is contained in:
parent
422efe87ce
commit
273f3ebcb7
4 changed files with 69 additions and 32 deletions
|
@ -6,7 +6,6 @@
|
|||
"alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" },
|
||||
"auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" },
|
||||
"auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" },
|
||||
"auto-jdtls.nvim": { "branch": "main", "commit": "3851cb9539283972d53ac24a3fd00a9decfdc717" },
|
||||
"auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" },
|
||||
"auto-lsp.nvim": { "branch": "main", "commit": "2a5ade9f78a1c60d747396445d4205352d2491db" },
|
||||
"auto-lualine.nvim": { "branch": "main", "commit": "fc8557f61dc1da12a8b90167a49420958b991d8c" },
|
||||
|
@ -46,14 +45,14 @@
|
|||
"nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" },
|
||||
"nvim-jdtls": { "branch": "master", "commit": "c4279b8ffce9b64eb302056d78dfebc2968a49bc" },
|
||||
"nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "4cb925e96288a71409a86c84fd97f4434a95453e" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" },
|
||||
"nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" },
|
||||
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
||||
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
|
||||
"nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" },
|
||||
"nvim-scrollview": { "branch": "main", "commit": "f7f611330a8f7cd00dc81538fec369611be678ed" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "28eac2801b201f301449e976d7a9e8cfde053ba3" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "bb06afa3f1111780932b3c5493ad65473ce85f9d" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "7646c1c12a3121562aa87fd79aace48c728ac096" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
|
||||
|
@ -61,6 +60,7 @@
|
|||
"rainbow-delimiters.nvim": { "branch": "master", "commit": "f22496dfdd46da4d571f5254c72eff65ff5a1c27" },
|
||||
"refactoring.nvim": { "branch": "master", "commit": "53ed6854e0bba64d467c58e87084dcf8b1c22d36" },
|
||||
"smart-splits.nvim": { "branch": "master", "commit": "ea4702652cb1d18811d60f2e206787602a2e946c" },
|
||||
"springboot-nvim": { "branch": "main", "commit": "3e81c0ed2ca8c05d2cfcbab04addfaa3792dbcb0" },
|
||||
"symbols-outline.nvim": { "branch": "master", "commit": "964c5902243446124417a3a9e9454f5ef032cc36" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" },
|
||||
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "a39fa4c92268832f6034306793b8acbfec2a7549" },
|
||||
|
|
|
@ -82,25 +82,62 @@ M.opts = {
|
|||
return vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
end,
|
||||
|
||||
-- Where are the config and workspace dirs for a project?
|
||||
jdtls_config_dir = function(project_name)
|
||||
return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/config"
|
||||
get_jdtls = function()
|
||||
local function check_os()
|
||||
local uname = vim.loop.os_uname().sysname
|
||||
if uname == "Darwin" then
|
||||
return "mac"
|
||||
elseif uname == "Windows_NT" then
|
||||
return "win"
|
||||
elseif uname == "Linux" then
|
||||
return "linux"
|
||||
else
|
||||
return "unknown"
|
||||
end
|
||||
end
|
||||
local mason_registry = require("mason-registry")
|
||||
local jdtls = mason_registry.get_package("jdtls")
|
||||
local jdtls_path = jdtls:get_install_path()
|
||||
local launcher = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar")
|
||||
local SYSTEM = check_os()
|
||||
local config = jdtls_path .. "/config_" .. SYSTEM
|
||||
local lombok = jdtls_path .. "/lombok.jar"
|
||||
return launcher, config, lombok
|
||||
end,
|
||||
|
||||
jdtls_workspace_dir = function(project_name)
|
||||
return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/workspace"
|
||||
local function get_workspace()
|
||||
local home = os.getenv("HOME")
|
||||
local workspace_path = home .. "/code/workspace/"
|
||||
local workspace_dir = workspace_path .. project_name
|
||||
return workspace_dir
|
||||
end
|
||||
return get_workspace()
|
||||
end,
|
||||
cmd = { vim.fn.exepath("jdtls") },
|
||||
full_cmd = function(opts)
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
local cmd = vim.deepcopy(opts.cmd)
|
||||
if project_name then
|
||||
vim.list_extend(cmd, {
|
||||
"-configuration",
|
||||
opts.jdtls_config_dir(project_name),
|
||||
"-data",
|
||||
opts.jdtls_workspace_dir(project_name),
|
||||
})
|
||||
end
|
||||
local launcher, os_config, lombok = opts.get_jdtls()
|
||||
local cmd = {
|
||||
"java",
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
"-Dosgi.bundles.defaultStartLevel=4",
|
||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dlog.protocol=true",
|
||||
"-Dlog.level=ALL",
|
||||
"-Xmx1g",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens",
|
||||
"java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens",
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
"-javaagent:" .. lombok,
|
||||
"-jar",
|
||||
launcher,
|
||||
"-configuration",
|
||||
os_config,
|
||||
"-data",
|
||||
opts.jdtls_workspace_dir(project_name),
|
||||
}
|
||||
return cmd
|
||||
end,
|
||||
|
||||
|
@ -178,21 +215,21 @@ M.attach_jdtls = function(op)
|
|||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
-- stylua: ignore
|
||||
if client and client.name == "jdtls" then
|
||||
-- M.jdtls_keymaps()
|
||||
-- M.lsp_keymaps()
|
||||
if M.opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(M.opts.dap)
|
||||
require("jdtls.dap").setup_dap_main_class_configs(M.opts.dap_main)
|
||||
end
|
||||
|
||||
-- User can set additional keymaps in opts.on_attach
|
||||
if M.opts.on_attach then
|
||||
M.opts.on_attach(args)
|
||||
end
|
||||
-- stylua: ignore
|
||||
if client and client.name == "jdtls" then
|
||||
-- M.jdtls_keymaps()
|
||||
-- M.lsp_keymaps()
|
||||
if M.opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(M.opts.dap)
|
||||
require("jdtls.dap").setup_dap_main_class_configs(M.opts.dap_main)
|
||||
end
|
||||
|
||||
-- User can set additional keymaps in opts.on_attach
|
||||
if M.opts.on_attach then
|
||||
M.opts.on_attach(args)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
@ -28,7 +28,7 @@ M = {
|
|||
},
|
||||
{
|
||||
"mfussenegger/nvim-jdtls",
|
||||
dependencies = { "pojokcodeid/auto-jdtls.nvim" },
|
||||
-- dependencies = { "pojokcodeid/auto-jdtls.nvim" },
|
||||
ft = { "java" },
|
||||
enabled = true,
|
||||
-- your opts go here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue