williamboman / mason.nvim

Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.
Apache License 2.0
7.24k stars 258 forks source link

Programatical way to register custom mason registry #1749

Open s1n7ax opened 4 days ago

s1n7ax commented 4 days ago

I've searched open issues for similar requests

Is your feature request related to a problem? Please describe.

I'm working on nvim-java plugin and following is the way I have added the nvim-java/mason-registry.

https://github.com/nvim-java/nvim-java/blob/26b3d3f38412b8548af40138c8d6ad7787b7ee81/lazy.lua#L14-L19

This obviously only works if opts passed from the plugin actually passed into the mason setup function. It seems a lot of people still doing config = function(_, opts) mason.setup({}) end ignoring the opts passed into the config function. So, packages only available via my repository failed to install.

Most confusing one is jdtls because in the main repository there is jdtls, it fails due to invalid url (because they are using the release date in the jdtls download link).

I'm just wondering if there is a way to add the registry programmatically for local mason instance just to install packages required to run nvim-jdtls.

This is how we are installing pkgs using the global mason instance. https://github.com/atm1020/nvim-java/blob/26b3d3f38412b8548af40138c8d6ad7787b7ee81/lua/java/utils/mason.lua?plain=1#L65-L78

Describe the solution you'd like

Something like,

local new_reg = mason_registry:new()
new_reg:add('nvim-java/mason-registry')
new_reg:install('jdtls')

Describe potential alternatives you've considered

No response

Additional context

No response