mason.nvim
mason.nvim copied to clipboard
Command `MasonInstallSync <languages> ...`
I've searched open issues for similar requests
Yes
Is your feature request related to a problem? Please describe.
I'm trying to automate installation of a neovim configuration for some others who are not aware of the neovim landscape, installing plugins etc...
As part of this I am doing headless installs using Packer, Mason, and Treesitter. This is much easier with treesitter as they have TSInstallSync and packer has a hook autocommand which can be used to close upon completion of plugin installation.
Describe the solution you'd like
It would be great to be able to do:
nvim --headless "MasonInstallSync ..." -c qa
Describe potential alternatives you've considered
I tried having Mason install things while treesitter is also installing some language grammars, essentially trying to rely on treesitter to take longer than Mason. This kind of works but not really, I'm artificially adding treesitter parsers to try ensure Mason can install things.
nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerSync"
nvim --headless -c "LspInstall bashls yamlls taplo esbonio marksman sumneko_lua pyright jsonls clangd" \
-c "MasonInstall ruff mypy actionlint flake8 yamllint yamlfmt black clang-format jq shfmt" \
-c "TSInstallSync lua python query json markdown markdown_inline diff gitcommit gitignore help make bash regex toml vim yaml git_rebase" \
-c qa
Note that LspInstall from mason-lspconfig is also being used which as far as I'm aware just hooks into Mason.
I've considered seeing if I can hook into the mason lua api but I feel this is not an ideal solution, as I would essentially be trying to implement a MasonInstallSync function.
Additional context
Version: NVIM v0.8.1
Hello! So the :MasonInstall command should install packages in "sync" mode if there are no UIs attached (i.e. headless). Are you not experiencing this? The :LspInstall command does no such thing so I'd recommend you only invoke the :MasonInstall from scripts.
Since it'll be running in blocking mode you can leverage shell job control for parallelization if that's desirable:
nvim --headless -c "MasonInstall rust-analyzer" &
nvim --headless -c "TSInstallSync rust" &
wait
Thanks for the reply!
I think you nailed the issue with :LspInstall doing no such thing. I naively assumed that mason-lsp-config would be using Mason under the hood and so inherit the --headless sync property. I still think having this as an explicit option might help with mason-lsp-config to also install in sync but I think this solves my issue. Many thanks :)
If you don't plan on this feature, please feel free to close the issue.
Makes a lot of sense, also from a code maintenance point of view (no need for two different implementations) - should be fixed in https://github.com/williamboman/mason-lspconfig.nvim/pull/112.