Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: update mason API usage for nvim-java compatibility#89

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Kabil777 wants to merge2 commits intonvim-java:main
base:main
Choose a base branch
Loading
fromKabil777:fix/mason-api-update

Conversation

@Kabil777
Copy link

Summary

This PR updates deprecated Mason APIs (get_install_path) used innvim-java-core to work with Mason v2.2.0+.

Changes

  • Updated:init.lua inls/servers/jdtls to usevim.fn.expand("$MASON/…") for finding JDK paths.
  • Updated:utils/mason.lua to replace deprecated Mason API calls with standard path functions (vim.fn.stdpath).
  • Handled: safe usage ofget_package withpcall to avoid crashes when packages are not installed.

Motivation

Recent versions ofmason.nvim removed or changed theget_install_path() method, breaking integration withnvim-java. This patch restores compatibility.

Testing

Tested with:

  • Mason v2.2.0

lukasl-dev, Morph01, mholtzscher, adelarsq, and chiragverma11 reacted with thumbs up emojiDaniloMekic reacted with heart emoji
@Coding4Hours

This comment was marked as abuse.

@Coding4Hours

This comment was marked as abuse.

@Coding4Hours

This comment was marked as abuse.

@gierdo
Copy link

gierdo commentedMay 11, 2025
edited
Loading

this error is so stupid and i need java because im training for usaco

You can install mason in version 1.x, or alternatively use nvim-java-compatibility from Kabil777's fork.

How you can do that depends on you plugin manager and your configuration, though. So it's a bit hard to guide you.

With lazy, e.g., you can do

  {    "williamboman/mason.nvim",    branch = "v1.x",...

Or you can apply the fix proposed here:

LazyVim/LazyVim#6053 (comment)

Or you can do this:

  {    "nvim-java/nvim-java",...    dependencies = {      {        "nvim-java/nvim-java-core",        url = "https://github.com/Kabil777/nvim-java-core.git",        branch = "fix/mason-api-update",      },    },  },

@Coding4Hours

This comment was marked as abuse.

@Zeioth
Copy link

@s1n7ax merging this PR is also necessary.

@s1n7ax
Copy link
Member

this error is so stupid and i need java because im training for usaco

@Coding4Hours I don't give a shit wtf you are training for. Don't know how branches work? Then stop trying you will be replaced by AI in few months anyway

Zeioth, adelarsq, and diego-velez reacted with laugh emoji

---@returnstring|nil
functionM.get_pkg_path(pkg_name)
returnmason_registry.get_package(pkg_name):get_install_path()
localmason_data_path=vim.fn.stdpath("data").."/mason/packages/"..pkg_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In prev you used $MASON variable but here getstdpath?

---@returnstring
functionM.get_shared_path(pkg_name)
returnvim.fn.glob('$MASON/share/'..pkg_name)
localmason_share_path=vim.fn.stdpath("data").."/mason/share/"..pkg_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can't we use $MASON env variable?

@s1n7ax
Copy link
Member

Release notes states that the way to get the path is using$MASON environment variable. You could fix all occurrences to use$MASON or I fix and merge in few days. Formatting has to be fixed as well

adelarsq reacted with thumbs up emoji

@ahakanbaba
Copy link

Thank you very much for the hard work here. If I may ask, what would it take to push this PR through. It would be great to unblock the mason backward compatibility problem.

@s1n7ax
Copy link
Member

@ahakanbaba The last time I accepted a mason 2.0 compatibility PR, it was broken on mason 1.0 as well as on mason 2.0. Now that I have some time to think about it, the changes should think about backward compatibility as well. I think I should do this myself but at the same time I don't have much time. too busy with personal stuff.

adelarsq reacted with thumbs up emoji

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

Reviewers

@s1n7axs1n7axs1n7ax requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@Kabil777@Coding4Hours@gierdo@Zeioth@s1n7ax@ahakanbaba

[8]ページ先頭

©2009-2025 Movatter.jp