mirror of
https://github.com/Baipyrus/nvim-config.git
synced 2024-11-14 21:13:49 +00:00
import default settings of nvim-jdtls
This commit is contained in:
parent
d0fed4363e
commit
1fe59378ba
62
lua/plugins/nvim-jdtls.lua
Normal file
62
lua/plugins/nvim-jdtls.lua
Normal file
@ -0,0 +1,62 @@
|
||||
return {
|
||||
{
|
||||
"mfussenegger/nvim-jdtls",
|
||||
opts = function()
|
||||
local mason_registry = require("mason-registry")
|
||||
local lombok_jar = mason_registry.get_package("jdtls"):get_install_path() .. "/lombok.jar"
|
||||
return {
|
||||
-- How to find the root dir for a given filename. The default comes from
|
||||
-- lspconfig which provides a function specifically for java projects.
|
||||
root_dir = LazyVim.lsp.get_raw_config("jdtls").default_config.root_dir,
|
||||
|
||||
-- How to find the project name for a given root dir.
|
||||
project_name = function(root_dir)
|
||||
return root_dir and vim.fs.basename(root_dir)
|
||||
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"
|
||||
end,
|
||||
jdtls_workspace_dir = function(project_name)
|
||||
return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/workspace"
|
||||
end,
|
||||
|
||||
-- How to run jdtls. This can be overridden to a full java command-line
|
||||
-- if the Python wrapper script doesn't suffice.
|
||||
cmd = {
|
||||
vim.fn.exepath("jdtls"),
|
||||
string.format("--jvm-arg=-javaagent:%s", lombok_jar),
|
||||
},
|
||||
full_cmd = function(opts)
|
||||
local fname = vim.api.nvim_buf_get_name(0)
|
||||
local root_dir = opts.root_dir(fname)
|
||||
local project_name = opts.project_name(root_dir)
|
||||
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
|
||||
return cmd
|
||||
end,
|
||||
|
||||
-- These depend on nvim-dap, but can additionally be disabled by setting false here.
|
||||
dap = { hotcodereplace = "auto", config_overrides = {} },
|
||||
dap_main = {},
|
||||
test = true,
|
||||
settings = {
|
||||
inlayHints = {
|
||||
parameterNames = {
|
||||
enabled = "all",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user