Skip to content

Commit

Permalink
fix(mason)!: rename MasonUpdate and MasonUpdateAll to `AstroMason…
Browse files Browse the repository at this point in the history
…Update` and `AstroMasonUpdateAll`
  • Loading branch information
mehalter committed Apr 1, 2024
1 parent 1ad1e1e commit 9be64b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
20 changes: 1 addition & 19 deletions lua/astronvim/plugins/configs/mason.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
return function(_, opts)
require("mason").setup(opts)

-- TODO: AstroNvim v4: change these auto command names to not conflict with core Mason commands
local cmd = vim.api.nvim_create_user_command
cmd("MasonUpdate", function(options) require("astrocore.mason").update(options.fargs) end, {
nargs = "*",
desc = "Update Mason Package",
complete = function(arg_lead)
local _ = require "mason-core.functional"
return _.sort_by(
_.identity,
_.filter(_.starts_with(arg_lead), require("mason-registry").get_installed_package_names())
)
end,
})
cmd("MasonUpdateAll", function() require("astrocore.mason").update_all() end, { desc = "Update Mason Packages" })

for _, plugin in ipairs { "mason-lspconfig", "mason-null-ls", "mason-nvim-dap" } do
pcall(require, plugin)
end
vim.tbl_map(function(mod) pcall(require, mod) end, { "mason-lspconfig", "mason-null-ls", "mason-nvim-dap" })
end
17 changes: 15 additions & 2 deletions lua/astronvim/plugins/mason.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@ return {
"MasonUninstall",
"MasonUninstallAll",
"MasonLog",
"MasonUpdate", -- AstroNvim extension here as well
"MasonUpdateAll", -- AstroNvim specific
},
dependencies = {
{
"AstroNvim/astrocore",
opts = function(_, opts)
local maps = opts.mappings
local cmd = opts.commands
if require("astrocore").is_available "mason.nvim" then
maps.n["<Leader>pm"] = { function() require("mason.ui").open() end, desc = "Mason Installer" }
maps.n["<Leader>pM"] = { function() require("astrocore.mason").update_all() end, desc = "Mason Update" }
cmd.AstroMasonUpdate = {
function(options) require("astrocore.mason").update(options.fargs) end,
nargs = "*",
desc = "Update Mason Package",
complete = function(arg_lead)
local _ = require "mason-core.functional"
return _.sort_by(
_.identity,
_.filter(_.starts_with(arg_lead), require("mason-registry").get_installed_package_names())
)
end,
}
cmd.AstroMasonUpdateAll =
{ function() require("astrocore.mason").update_all() end, desc = "Update Mason Packages" }
end
end,
},
Expand Down

0 comments on commit 9be64b9

Please sign in to comment.