Repository navigation
mason.nvim update tools from command line #2116
|
Thank you for Mason! :) It's truly valuable and makes working in Neovim even more of a pleasure. I would like to update all Mason-installed tools externally to an open nvim editor. I currently do this for all my lazy.nvim-installed plugins via ❯ nvim --headless '+MasonUpdate!' +qa
Error in command line:
E492: Not an editor command: MasonUpdate!My environment: ❯ nvim --version
NVIM v0.12.5
Build type: Release
LuaJIT 2.1.1788856981
neovim > lazy > mason.nvim:
mason.nvim 13.45ms VeryLazy
dir /Users/jlf/.local/share/nvim/lazy/mason.nvim
url https://github.com/mason-org/mason.nvim
version 2.3.1
tag v2.3.1
branch main
commit 2a6940a
readme README.md
help |mason.nvim|
keys <leader>cm
event VeryLazy
cmd Mason I'm not a Neovim expert by any stretch, am I doing something obviously wrong? Any help to get this working would be tremendously appreciated! Thanks again for Mason! :) |
Replies: 2 comments 1 reply
|
Two things are going on here:
There's no built-in "upgrade everything" command, but the registry API makes it a one-liner. This refreshes the registry, then reinstalls only the packages whose installed version differs from the latest: nvim --headless '+Lazy! load mason.nvim' '+MasonUpdate' \
'+lua local names = {} for _, p in ipairs(require("mason-registry").get_installed_packages()) do if p:get_installed_version() ~= p:get_latest_version() then table.insert(names, p.name) end end if #names > 0 then vim.cmd("MasonInstall " .. table.concat(names, " ")) end' \
+qa
|
|
@XNinety9 you're amazing, thank you so much :-) |
Two things are going on here:
VeryLazy/cmd), and in headless modeVeryLazynever fires, so the:Mason*commands don't exist yet. You can load it explicitly with+Lazy! load mason.nvimfirst.:MasonUpdateonly updates the registry (the list of available versions), not the installed tools. It doesn't take a!either.There's no built-in "upgrade everything" command, but the registry API makes it a one-liner. This refreshes the registry, then reinstalls only the packages whose installed version differs from the latest: