Skip to content

Autoupdate to Mason packages #1241

Answered by yutkat
Jendker asked this question in Q&A
Discussion options

You must be logged in to vote

I think that kind of functionality is not provided. I think it's most common to use :Mason commands and type U instead of automatically updating it.

You can create a command like this for simple automatic updates.

vim.api.nvim_create_user_command("MasonUpgrade", function()
	local registry = require("mason-registry")
	registry.refresh()
	registry.update()
	local packages = registry.get_all_packages()
	for _, pkg in ipairs(packages) do
		if pkg:is_installed() then
			pkg:install()
		end
	end
	vim.cmd("doautocmd User MasonUpgradeComplete")
end, { force = true })

Execute this command periodically by cron or something.

nvim --headless -c "autocmd User MasonUpgradeComplete sleep 100m | qall" -c '

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Jendker
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants