Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration to auto install missing tools #103

Closed
alisonjenkins opened this issue Jul 20, 2022 · 9 comments
Closed

Configuration to auto install missing tools #103

alisonjenkins opened this issue Jul 20, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@alisonjenkins
Copy link

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

Not a problem

Describe the solution you'd like

If possible I would like a configuration option to allow passing a table of tools that I would like Mason to automatically install so that when I copy my config to a new machine that it will automatically install all the required tools for my configuration rather than me having to manually install each via the UI.

Describe potential alternatives you've considered

No response

Additional context

No response

@alisonjenkins alisonjenkins added the enhancement New feature or request label Jul 20, 2022
@WhoIsSethDaniel
Copy link
Contributor

Hi @alanjjenkins , you can try https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim which does exactly this. I wrote it for the very use-case you mention.

@alisonjenkins
Copy link
Author

Fantastic thanks @WhoIsSethDaniel.

Is it worth us putting this in the extensions area of the README for Mason to save someone else putting a duplicate issue in for this?

@alisonjenkins
Copy link
Author

Fantastic thanks @WhoIsSethDaniel.

Is it worth us putting this in the extensions area of the README for Mason to save someone else putting a duplicate issue in for this?

Created PR: #104 for this.

@williamboman
Copy link
Owner

I think I'll open up a Wiki page for these things! I will likely also extract the mason-lspconfig extension into its own plugin, to make boundaries clearer but also promote more people to write similar extensions like mason-dap and mason-null-ls (ideally such extensions wouldn't be required, but there are gaps to fill).

So to answer the original topic; I have been wanting to incorporate something like this into mason core, but before doing so I'd like to make sure it's solid and well thought out. Some concerns I have are:

  • Need to think about how to handle new versions
    • Automatic checks for new versions need to be scheduled somehow, as to not do them every time you launch neovim
    • Immediately upgrading to a new version as soon as it's available will likely lead to some pretty disrupting experiences, should there be breaking changes in the new version. At the very least, should there be some mechanism that tries to parse versions and try to assess compatibility by conventional methods (semver etc.)?
  • Need to think about how to handle short-lived neovim sessions - are there some heuristics we can use to decide to commit to a package upgrade (e.g, session has reached X seconds)
  • This one's a bit easier, but need to figure out a nice outlet for displaying progress other than the :Mason window. Echoing stdout & stderr (like treesitter's :TSUpdate) would be one way. I've also wanted to explore windows like the one provided by https://github.com/j-hui/fidget.nvim (keeping an 👁️ on Use as a library / low-level API? j-hui/fidget.nvim#70)

@alisonjenkins
Copy link
Author

Need to think about how to handle short-lived neovim sessions - are there some heuristics we can use to decide to commit to a package upgrade (e.g, session has reached X seconds)

A thought on this... maybe have the plugin upgrade / install to a temp dir on the same filesystem first and then move the result on completion. That way it can be atomic as moves are atomic within the same file system.

@williamboman
Copy link
Owner

williamboman commented Jul 21, 2022

A thought on this... maybe have the plugin upgrade / install to a temp dir on the same filesystem first and then move the result on completion. That way it can be atomic as moves are atomic within the same file system.

This is already done actually! However, there are some tools that will encode full paths into build artifacts (pip does this with the shebangs in the executables it creates for example). These installations has to run in their final installation directory because moving their location after installation/build will break them - for example here's when the pip manager "promotes" the temporary installation directory. Homebrew works around this by doing a search and replace 😬.

@alisonjenkins
Copy link
Author

However, there are some tools that will encode full paths into build artifacts (pip does this with the shebangs in the executables it creates for example).

For this specific case wouldn't it make sense to replace the shbangs and preserve the behavior? That is fairly easy using awk and specifically targeting files ending in .py. I haven't yet looked under the covers on the code base but if I get time I will take a look and see if I can find a sane way to do this and put in a PR for your consideration.

@bbkane
Copy link

bbkane commented Aug 2, 2022

Perhaps instead of using a heuristic to determine whether NeoVim will be open long enough for Mason to install tools, Mason should print a message at the bottom of the screen: tools required from Mason Neovim configuration not installed: run :MasonInstallRequired to install: tool-a, tool-b, lsp-c. Then users can run that at their convenience.

@robbienohra
Copy link

robbienohra commented Aug 3, 2022

automatic_installation is a supported configuration option in nvim-lsp-installer — is there a reason this was omitted in mason.nvim? 🤔

ah sorry I see it was factored into a separate module — wicked!

https://github.com/williamboman/mason-lspconfig.nvim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Closed
Development

No branches or pull requests

5 participants