feat(java): enable Lombok support in jdtls (#3852)
jdtls needs an argument passed to the JVM to load Lombok as an agent. Mason downloads `lombok.jar`so we can use that ## What is this PR for? Configures Lombok support in `jdtls` ; this removes a lot of red underlines in Java projects that use it. Changes this  To this  - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. Co-authored-by: Adrian Wilkins <adrian.wilkins.contractor@dvla.gov.uk>
This commit is contained in:
@ -71,6 +71,8 @@ return {
|
||||
dependencies = { "folke/which-key.nvim" },
|
||||
ft = java_filetypes,
|
||||
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.
|
||||
@ -91,7 +93,10 @@ return {
|
||||
|
||||
-- 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") },
|
||||
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)
|
||||
|
Reference in New Issue
Block a user