Skip to content

Issue events when Mason actions complete (Install/Update/Uninstall) #2074

Description

@Raizento

I've searched open issues for similar requests

  • Yes

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

No

Describe the solution you'd like

I'd like Mason to issue a User event when an action is done.

One use case for this would be enabling an LSP once installed with Mason. What currently needs to be done (when using version v0.12.x):

  • Install LSP with Mason
  • (optional) configure LSP using vim.lsp.config()
  • Enable LSP using vim.lsp.enable()

These steps need to be done manually. While not too much work, I think it would be nice if we were able to hook into a package's "lifecycle" and do this automatically.

I have not given too much thought into what the event's data might look like, but I suppose it should include at least the following fields:

  • kind: One of Install/Update/Uninstall
  • name: Name of the package. Useful for querying more information using mason-registry

Events with kind Update might also include the old_version and the new_version.

While I do not have that much experience using packages outside of LSPs, I'd imagine these lifecycle events might come in handy when setting some packages up as well (e.g. by creating some directories/loading some configuration or cleaning them up when the package is removed).

Describe potential alternatives you've considered

One potential alternative is doing the steps described above manually. This might happen via a keymap, on startup, when leaving a window with filetype mason... but all of these solutions are (in my opinion) rather hacky and might not translate well when running a headless instance of nvim.

Another alternative would be using https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim to at least events for installations/updates. While definitely useful, I feel like this should be functionality provided by Mason itself. The events I described would also include an event for uninstalling a package which is missing from mason-tool-installer.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions