Skip to content

feature: Mason 2.0 support #384

Closed

Description

@s1n7ax

Mason 2.0 migration

Workaround (Lazyvim)

At the moment nvim-java does not support Mason 2.0. If you are seeing errors please pin the mason & mason-lspconfig to 1.x

  • Create ~/.config/nvim/lua/plugins/mason-workaround.lua
  • Add following spec
return {
  { "mason-org/mason.nvim", version = "^1.0.0" },
  { "mason-org/mason-lspconfig.nvim", version = "^1.0.0" },
}

Blocking

Activity

  1. ginolegigot commented on May 17, 2025

    @ginolegigot

    hey,
    idk if it's related but in case, regarding this issue mason-org/mason.nvim#1939 (comment) which origin is from several occurence of a declaration of a mason.setup().
    From my understanding, setting require("java").setup() also set a require("mason").setup() under the hood. However calling opts in mason plugin declaration (for instance to configure the mason nvim-java registry) also triggers a require("mason").setup() which leads to the aforementionned issue

  2. logrusx commented on May 25, 2025

    @logrusx
    Collaborator

    Is this why lombok stopped working?

  3. zlendo1 commented on May 31, 2025

    @zlendo1

    Man, this sucks. Hope it gets resolved soon. Can we offer any assistance?

  4. reckseba commented on Jun 13, 2025

    @reckseba

    I am not sure if this is why my setup is not working. I have:

    • cloned the latest kickstart into ~/.config/nvim-kickstart
    • integrated what is necessary into the init.lua
    • Created an alias: alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim'
    • Spun up nvim with nvim-kickstart .

    When checking :Mason I can tell that jdtls was not installed.

    Is that what you @s1n7ax mean by "At the moment nvim-java does not support Mason 2.0"? Though your recommended mitigration does not work for me.

    Am I at the right spot?

    Thanks and have a nice weekend everybody :)

  5. snoweuph commented on Jun 19, 2025

    @snoweuph

    This issue should be a big warning at the top of the Readme.
    I thought that I messed up load orders or something, but no, it's this.

    Fixing mason to v1 fixed it for me though, it would be cool if something like this is in the readme, because that's where people look first when configuring a plugin.

  6. Slava-Ini commented on Jun 25, 2025

    @Slava-Ini

    Pretty annoying issue, couldn't fix for a while - for some reason get_installed_version kept popping up in different place

    So for me that workaround solved the issue:

    • Pinning Mason and Mason LSP versions to ^1 as suggested by @s1n7ax
    • Removing lazy-lock.json file
    • Removing /home/{user}/.local/share/nvim/lazy
    • Reinstalling plugins
  7. logrusx commented on Jun 25, 2025

    @logrusx
    Collaborator

    for some reason get_installed_version kept popping up in different place

    I've locally fixed all Mason API calls, including in nvim-java-core and it still doesn't work. It seems it isn't only that.

    Only pinning mason and mason-lspconfig to v1 works. However the following is not entirely complete:

    So for me that workaround solved the issue:

    * Pinning Mason and Mason LSP versions to ^1 as suggested by [@s1n7ax](https://github.com/s1n7ax)
    
    * Removing `lazy-lock.json` file
    
    * Removing `/home/{user}/.local/share/nvim/lazy`
    
    * Reinstalling plugins
    

    If you already have packages installed with Mason v2, then you need to purge /home/{user}/.local/share/nvim/mason as well. The easiest would be to purge the entire /home/{user}/.local/share/nvim directory. The worst that could happen is a few hundred of megabytes extra download.

  8. logrusx commented on Jul 27, 2025

    @logrusx
    Collaborator

    I'm trying to move nvim-java forward here, whoever wants to try to help, please join.

  9. logrusx commented on Jul 29, 2025

    @logrusx
    Collaborator

    Migration is complete in my repo along with some fixes. Go check it out. Check the branches and the discussion for details. Skip the earlier comments and see the last few.

  10. logrusx commented on Jul 31, 2025

    @logrusx
    Collaborator

    @s1n7ax I've created 2 PR's in nvim-java and nvim-java-core along with one in starter-kickstart that should move nvim-java to Mason 2.0 compatibility.

    To keep nvim-java running on Mason 2.0 at its current state, fixes are necessary in the custom mason registry. I'm not interested in using it so I haven't fixed it. Also I found it hard to find documentation what and if I need to change something related to Mason 2.0. I think it might be as simple as just fixing the download URL's. I'm leaving this job for you.

    I've also modified nvim-java and nvim-java-core to use the official mason repository only. I'm not creating PR's for it because I don't know if you would be willing to merge it. You can review the changes in my repo and if you want, I'll prepare PR's for you or you can do it yourself.

    Another modification I've made is to be able to use latest versions of everything by passing * for the version.

    Let me know if you need something from my side.

    p.s. Thank you very much for the effort you've put to put nvim-java together.

  11. s1n7ax commented on Jul 31, 2025

    @s1n7ax
    MemberAuthor

    Does this still have the compatibility for Mason 1.0? Lazyvim still is using 1.0

  12. logrusx commented on Jul 31, 2025

    @logrusx
    Collaborator

    Does this still have the compatibility for Mason 1.0? Lazyvim still is using 1.0

    No. I saw it was possible but I decided I'm not going down that path.

    Just tag the new release with v3.0.0 and add to the README that people need to use version = "^2.0.0" for mason 1.0.

  13. s1n7ax commented on Jul 31, 2025

    @s1n7ax
    MemberAuthor

    make sense. Please go ahead and create PRs. Could you please mention all the PRs that should be merged here as well.

  14. logrusx commented on Aug 2, 2025

    @logrusx
    Collaborator

    @s1n7ax it's taking a bit more time but I might actually be able to make it backward compatible. Stay tuned.

  15. logrusx commented on Aug 3, 2025

    @logrusx
    Collaborator

    @s1n7ax I need issue #403 closed to spare you resolving conflicts. PR #405 is linked and resolves it. Could you please also look at #406. It would be nice to have that closed too.

  16. s1n7ax commented on Aug 4, 2025

    @s1n7ax
    MemberAuthor

    #405 and #406 merged

  17. logrusx commented on Aug 5, 2025

    @logrusx
    Collaborator

    @s1n7ax PR's nvim-java/nvim-java-core#93 (issue nvim-java/nvim-java-core#91) and #402.

    Then nvim-java/starter-kickstart#3 should make the necessary changes for kickstart to work with mason 2.0

  18. s1n7ax commented on Aug 6, 2025

    @s1n7ax
    MemberAuthor

    Merged. Now you should be able to use Mason 1.0 as well as Mason 2.0. @logrusx Thanks for the hard work. Hope we can see more contributions in the future from Java devs as I'm no longer a Java dev nor hoping to contribute to this.

  19. logrusx commented on Aug 6, 2025

    @logrusx
    Collaborator

    @logrusx Thanks for the hard work.

    Thank you too! Thank you too for that I've learned a lot from your code!

    Hope we can see more contributions in the future from Java devs as I'm no longer a Java dev nor hoping to contribute to this.

    That's my hope too. That's why I wanted the changes to be merged back and not spread around countless forks.

  20. Zeioth commented on Aug 6, 2025

    @Zeioth
    Contributor

    I've tested nvim-java v3.0 with mason 2.0 and all seems to work fine. We are going to ship nvim-java with NormalNvim once more.

    EDIT: Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions