Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astrocommunity.pack.java troubles #262

Closed
psolyca opened this issue Jun 5, 2023 · 3 comments · Fixed by #265
Closed

astrocommunity.pack.java troubles #262

psolyca opened this issue Jun 5, 2023 · 3 comments · Fixed by #265

Comments

@psolyca
Copy link

psolyca commented Jun 5, 2023

Following PR ##245, there are some troubles starting Java.

:lua print(os.getenv("MASON")) gives the correct value /home/user/.local/share/nvim/mason

But when I open a .java file the JDTLS does not start.
The $MASON variable is not expanded. The lsp.log file show :

[START][2023-06-05 15:06:13] LSP logging initiated
[ERROR][2023-06-05 15:06:13] .../vim/lsp/rpc.lua:733	"rpc"	"java"	"stderr"	"Error: Unable to access jarfile /share/jdtls/plugins/org.eclipse.equinox.launcher.jar\n"
[ERROR][2023-06-05 15:06:14] .../vim/lsp/rpc.lua:733	"rpc"	"java"	"stderr"	"Error: Unable to access jarfile /share/jdtls/plugins/org.eclipse.equinox.launcher.jar\n"

I use a customized community.lua with :

{
    "mfussenegger/nvim-jdtls",
    opts = function()
      local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle", ".project" }
      local root_dir = require("jdtls.setup").find_root(root_markers)
      local home = os.getenv("HOME")
      local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
      local workspace_dir = home .. "/workspace/" .. project_name
      return {
        cmd = {
          '/usr/lib/jvm/java-17-openjdk-amd64/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',
          '-jar',
          vim.fn.expand "$MASON/share/jdtls/plugins/org.eclipse.equinox.launcher.jar",
          '-configuration',
          vim.fn.expand "$MASON/share/jdtls/config",
          '-data',
          workspace_dir,
        },
        root_dir = root_dir,
        init_options = {
          settings = {
            java = {
              autobuild = {
                enabled = false
              },
              import = {
                gradle = {
                  enabled = false,
                  wrapper = {
                    enabled = false,
                  }
                }
              },
            },
          }
        },
      }
      end
  },

The result is the same with it or not.

@sjcobb2022
Copy link
Contributor

sjcobb2022 commented Jun 6, 2023

I have this issue too. I'll try and see if I can fix it. Most likely a dependency issue.

@sjcobb2022
Copy link
Contributor

sjcobb2022 commented Jun 6, 2023

Alright pull request is up. The issue was that given the recent updates mason was no longer required so the $MASON variable wasn't being loaded in.

As mentioned in the pull request, you may also need to update your mason dependencies as there was a recent change which changes the path to the debug adapter jar files. I spent a while trying to figure out why my debugging wasn't functional, but it just needed a quick update.

Edit: the debug adapter issue was also mentioned in #245, my bad.

@psolyca
Copy link
Author

psolyca commented Jun 7, 2023

Thanks a lot, I couldn't find the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants