![java-deps](https://camo.githubusercontent.com/3498d379e352185e601e4419423e79704522bfe8aad177874924d64f9e539ead/68747470733a2f2f6a61766168656c6c6f2e6769746875622e696f2f6465762f6e76696d2d6c65616e2f696d616765732f6a6176612d646570732e706e67)
English
{
"JavaHello/java-deps.nvim",
lazy = true,
ft = "java",
dependencies = "mfussenegger/nvim-jdtls",
config = function()
require("java-deps").setup({})
end,
}
- 手动编译
vscode-java-dependency
git clone https://github.com/microsoft/vscode-java-dependency.git
cd vscode-java-dependency
npm install
npm run build-server
- 将
vscode-java-dependency
编译后的 jar
添加到 jdtls_config["init_options"].bundles 中
local jdtls_config = {}
local bundles = {}
-- ...
local java_dependency_bundle = vim.split(
vim.fn.glob(
"/path?/vscode-java-dependency/jdtls.ext/com.microsoft.jdtls.ext.core/target/com.microsoft.jdtls.ext.core-*.jar"
),
"\n"
)
if java_dependency_bundle[1] ~= "" then
vim.list_extend(bundles, java_dependency_bundle)
end
jdtls_config["init_options"] = {
bundles = bundles,
extendedClientCapabilities = extendedClientCapabilities,
}
jdtls_config["on_attach"] = function(client, buffer)
require("java-deps").attach(client, buffer)
-- 添加命令
local create_command = vim.api.nvim_buf_create_user_command
create_command(buffer, "JavaProjects", require("java-deps").toggle_outline, {
nargs = 0,
})
end
:lua require('java-deps').toggle_outline()
:lua require('java-deps').open_outline()
:lua require('java-deps').close_outline()