fix: update mason API usage for nvim-java compatibility#89
Conversation
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 Or you can apply the fix proposed here: LazyVim/LazyVim#6053 (comment) Or you can do this: |
|
@s1n7ax merging this PR is also necessary. |
@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 |
| ---@return string | nil | ||
| function M.get_pkg_path(pkg_name) | ||
| return mason_registry.get_package(pkg_name):get_install_path() | ||
| local mason_data_path = vim.fn.stdpath("data") .. "/mason/packages/" .. pkg_name |
There was a problem hiding this comment.
In prev you used $MASON variable but here get stdpath?
| ---@return string | ||
| function M.get_shared_path(pkg_name) | ||
| return vim.fn.glob('$MASON/share/' .. pkg_name) | ||
| local mason_share_path = vim.fn.stdpath("data") .. "/mason/share/" .. pkg_name |
There was a problem hiding this comment.
Can't we use $MASON env variable?
|
Release notes states that the way to get the path is using |
|
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. |
|
@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. |
Summary
This PR updates deprecated Mason APIs (
get_install_path) used innvim-java-coreto work with Mason v2.2.0+.Changes
init.luainls/servers/jdtlsto usevim.fn.expand("$MASON/…")for finding JDK paths.utils/mason.luato replace deprecated Mason API calls with standard path functions (vim.fn.stdpath).get_packagewithpcallto avoid crashes when packages are not installed.Motivation
Recent versions of
mason.nvimremoved or changed theget_install_path()method, breaking integration withnvim-java. This patch restores compatibility.Testing
Tested with: