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

java pack root_dir #1131

Open
4 tasks done
jsenjobs opened this issue Jul 26, 2024 · 6 comments
Open
4 tasks done

java pack root_dir #1131

jsenjobs opened this issue Jul 26, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@jsenjobs
Copy link

jsenjobs commented Jul 26, 2024

Checklist

  • I have searched through the AstroNvim documentation
  • I have searched through the existing issues of this project
  • I have searched the existing issues of plugins related to this issue
  • I can replicate the bug with the minimal repro.lua provided below

Neovim version (nvim -v)

0.10.0 release

Operating system/version

macOS 11.5

Terminal/GUI

noevidea

Describe the bug

java pack can not resolve root_dir when maven project with submodules

Steps to Reproduce

open a java maven project with submodules

Expected behavior

submodule--

Screenshots

No response

Additional Context

No response

Minimal configuration

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  -- stylua: ignore
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)

-- install plugins
local plugins = {
  { "AstroNvim/AstroNvim", import = "astronvim.plugins" },
  { "AstroNvim/astrocommunity" },

  -- add any other plugins/customizations here
  { import = "astrocommunity.pack.java"},
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here (autocommands, vim.filetype, etc.)
@jsenjobs jsenjobs added the bug Something isn't working label Jul 26, 2024
@ALameLlama
Copy link
Member

I've updated the repro config to include the the java pack. I'll see if I can find an example repo and have a play around with this later

@ALameLlama
Copy link
Member

ALameLlama commented Jul 26, 2024

I found this, will give it a try when i have some time
https://github.com/jitpack/maven-modular or https://github.com/anliksim/maven-template-bom

@ALameLlama
Copy link
Member

@AstroNvim/astrocommunity-maintainers Someone else might need to try and repro this, I run my stuff in VM and it doesn't seem to like it

[ERROR][2024-07-26 19:48:47] .../vim/lsp/rpc.lua:770	"rpc"	"/home/vagrant/maven-template-bom/.repro/data/nvim/mason/bin/lemminx"	"stderr"	"The current machine does not support all of the following CPU features that are required by the image: [CX8, CMOV, FXSR, MMX, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, POPCNT, LZCNT, AVX, AVX2, BMI1, BMI2, FMA].\nPlease rebuild the executable with an appropriate setting of the -march option."

@Uzaaft
Copy link
Member

Uzaaft commented Jul 28, 2024

I'll try sometime next week.

@Jaffex
Copy link

Jaffex commented Oct 18, 2024

Hi there, I noticed that this is related to the way that the pack identifies the root directory.

As defined in this line, the root directory is defined by finding any of the following files or directories:
{ ".git", "mvnw", "gradlew", "pom.xml", "build.gradle", ".project" }

The problem here being that the path is traversed in reverse.
So let's say I have a structure like the following:

rootproject
|
|--- subproject1
|     |--- build.gradle
|     |--- src/main/java
|            |---File1.java
|
|--- subproject2
|     |--- build.gradle
|     |--- src/main/java
|            |--- File2.java
|
|── settings.gradle

Now you open file rootproject/subproject1/src/main/java/File1.java and it will traverse the directory from java > main > src > subproject1 > rootproject to find the root directory. Since subproject1 will contain that subproject's build.gradle, it will assume that directory as being the root directory of your project - and therefore completely ignore anything within subproject2.

I've edited the value for root_markers in the init.lua of the pack to only look for either .git or gradlew as those for me are the best markers for finding the root directory.

The problem is, I don't know enough lua to figure out if I could just add this change to my configuration, so I edited it directly within .local/share/nvim/lua/astrocommunity/pack/java/init.lua - that works, but it of course breaks updates.

Can I configure the root_markers used by the pack/java/init.lua somehow via the configuration directory?

@Jaffex
Copy link

Jaffex commented Oct 18, 2024

The default defined by nvim-jdtls would be to use {".git", "mvnw", "gradlew"} instead, which would not stop at a build.gradle as well, so it might even be a sane default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants