williamboman / mason.nvim

Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.
Apache License 2.0
7.3k stars 261 forks source link

Add a `:MasonClean` command #825

Open cloudlena opened 1 year ago

cloudlena commented 1 year ago

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

williamboman commented 1 year ago

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?

cloudlena commented 1 year ago

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.

williamboman commented 1 year ago

What does :Lazy sync do?

cloudlena commented 1 year ago

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

anjos commented 1 year ago

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.

williamboman commented 1 year ago

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

yellowhat commented 1 year ago

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.

williamboman commented 1 year ago

Which commit are you on?

yellowhat commented 1 year ago

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

williamboman commented 1 year ago

where have you looked so far?

yellowhat commented 1 year ago

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".

9mm commented 11 months ago

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