mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.09k stars 62 forks source link

Lombok works but show me errors in others parts of the code #455

Closed EnriqueBravo115 closed 1 year ago

EnriqueBravo115 commented 1 year ago

LSP client configuration

local home = os.getenv('HOME')
local jdtls = require('jdtls')

local root_markers = {'gradlew', 'mvnw', '.git', 'pom.xml', 'build.gradle'}
local root_dir = require('jdtls.setup').find_root(root_markers)

local workspace_folder = home .. "/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t")

local config = {
  flags = {
    debounce_text_changes = 80,
  },
  root_dir = root_dir, 
  settings = {
    java = {
      format = {
        settings = {
          url = "~/.config/nvim/lang-servers/intellij-java-google-style.xml",
          profile = "GoogleStyle",
        },
      },
      signatureHelp = { enabled = true },
      completion = {
        favoriteStaticMembers = {
          "org.hamcrest.MatcherAssert.assertThat",
          "org.hamcrest.Matchers.*",
          "org.hamcrest.CoreMatchers.*",
          "org.junit.jupiter.api.Assertions.*",
          "java.util.Objects.requireNonNull",
          "java.util.Objects.requireNonNullElse",
          "org.mockito.Mockito.*"
        },
      },
      sources = {
        organizeImports = {
          starThreshold = 9999;
          staticStarThreshold = 9999;
        },
      },
      codeGeneration = {
        toString = {
          template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}"
        },
        useBlocks = true,
      },
    }
  },
  cmd = {
    "/usr/bin/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',
    '-Xms1g',
    '--add-modules=ALL-SYSTEM',
    '--add-opens', 'java.base/java.util=ALL-UNNAMED',
    '--add-opens', 'java.base/java.lang=ALL-UNNAMED',
    '-javaagent:' .. home .. '/Applications/lombok.jar',
    '-jar', vim.fn.glob('/home/nullboy/Applications/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar'),
    '-configuration', '/home/nullboy/Applications/jdtls/config_linux',
    '-data', workspace_folder,
  },
}

jdtls.start_or_attach(config)

Eclipse.jdt.ls version

1.21.0

Steps to Reproduce

Use lombok, this works with the autocompletion but show me errors in code

Expected Result

No errors in other parts of code

Actual Result

the method setname is undefined for the type lombok **

Juniar-Rakhman commented 1 year ago

I use lombok and it works just fine. Can you share a repo where I could replicate the issue?

mfussenegger commented 1 year ago

This is either a configuration issue or an issue with eclipse.jdt.ls. nvim-jdtls does nothing special in regards to lombok/diagnostics