mason.nvim icon indicating copy to clipboard operation
mason.nvim copied to clipboard

Add a `:MasonClean` command

Open cloudlena opened this issue 2 years ago • 12 comments
trafficstars

I've searched open issues for similar requests

Yes

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

I would like to manage my tools declaratively in a Lua config file. To do so, I'd like Mason to check, whether there are tools currently installed, that aren't in the config file.

Describe the solution you'd like

I would propose to add a :MasonClean command, that removes all tools that aren't specified in ensure_installed lists of the different config helpers like https://github.com/williamboman/mason-lspconfig.nvim, https://github.com/jay-babu/mason-null-ls.nvim or https://github.com/jay-babu/mason-nvim-dap.nvim.

For convenience, I would also propose a :MasonSync command which includes :MasonClean, :MasonInstall and eventually, after https://github.com/williamboman/mason.nvim/issues/445 is closed, something like the there proposed :MasonUpdateAll command.

This would provide a user experience like what we have for package managers like https://github.com/wbthomason/packer.nvim or https://github.com/folke/lazy.nvim.

Describe potential alternatives you've considered

No response

Additional context

No response

cloudlena avatar Dec 29 '22 13:12 cloudlena

Would you consider a lockfile (similar to lazy.nvim's lockfile mechanism) to be the source of truth, or are you looking for a programmatic, Lua-based, interface for managing desired package state?

williamboman avatar Apr 28 '23 18:04 williamboman

I think, the lockfile approach is great for reproducibility. However, personally, I've never interacted directly with the Mason lockfile, so I'm not sure how it works underneath. I just run :Lazy sync and would prefer something similar for Mason.

cloudlena avatar Apr 29 '23 10:04 cloudlena

What does :Lazy sync do?

williamboman avatar May 02 '23 14:05 williamboman

It runs install, clean and update for the Lazy package manager: https://github.com/folke/lazy.nvim#-usage

cloudlena avatar May 02 '23 17:05 cloudlena

I was looking for a sync command and I was pointed to this issue by the oracle. Sync execution would also help with programmatic updates. For example, I use something like this:

nvim --headless -c "Lazy! sync" -c "Lazy! log" +qa
nvim --headless -c 'MasonUpdate' -c 'sleep 10' +qa
nvim --headless -c 'TSUpdateSync' +qa

As of now, I have to sleep to get Mason to complete its task, and hope the number of seconds is enough.

anjos avatar Jun 07 '23 16:06 anjos

@anjos #1347 should fix :MasonUpdate to behave similarly to :MasonInstall in headless mode (i.e. synchronously blocking until completion).

williamboman avatar Jun 12 '23 23:06 williamboman

I have tried:

nvim -c "MasonUpdate" -c quitall

but it exists immediately.

nvim -c "MasonUpdate

completes the update but it does not exit.

Any suggestions?

Thanks.

yellowhat avatar Jun 13 '23 05:06 yellowhat

Which commit are you on?

williamboman avatar Jun 13 '23 14:06 williamboman

I have done a "+Lazy! sync" before writing that post and now, and I got the same behavior. How can I see which commit?

Thanks

yellowhat avatar Jun 13 '23 14:06 yellowhat

where have you looked so far?

williamboman avatar Jun 13 '23 14:06 williamboman

so :Mason then g? returns "registry version": "2023-06-13-loyal-east. But I am not sure where is the git folder downloaded by "Lazy".

yellowhat avatar Jun 13 '23 14:06 yellowhat

I think this would be an awesome idea. I just migrated to Neovim and Mason is fantastic. I love its ease of use for installing things.

One thing that I was conflicted on is the ease of use in installing anything/everything LSP wise, but then the conflicted nature of wanting to have everything 'solidified' in my config, explicitly.

I ended up deciding on explicitly defining everything, but a lockfile would be perfect, or uninstalling servers that are not specified. It's not super important I suppose, but keeping installation in sync with the config means there would be only one source of truth, while i could still use the interface to experiment with installing any kinds of new ones that I want

9mm avatar Aug 09 '23 17:08 9mm