What's the relationship between this plugin with williamboman/mason-lspconfig.nvim?
tristone13th opened this issue ยท 10 comments
mason-tool-installer
uses Mason's public API to do something that, currently, Mason does not do.
mason-tool-installer
uses Mason's public API to do something that, currently, Mason does not do.
But it seems mason-lspconfig.nvim can also do some auto installation work.
mason-lspconfig
can do some installation, that is true. You can use both. You can use one, the other, or neither. It depends on your needs. I don't use mason-lspconfig
for installation since I need to install a lot more than LSP servers. I use mason-lspconfig
for setup_handlers()
and I use mason-tool-installer
for all my installation.
OK, thanks!
@tristone13th I found a great example config doing what @WhoIsSethDaniel is doing here: https://github.com/alpha2phi/neovim-for-beginner/blob/main/lua/config/lsp/installer.lua
@WhoIsSethDaniel I don't get it. Can I move everything inside ensure_installed
of mason-lspconfig
to that of your plugin?
[...] I use mason-lspconfig for setup_handlers() and I use mason-tool-installer for all my installation.
Regarding this line, notice that mason-lspconfig
can accept things like bashls
, which should be valid according to the docs of mason, but your plugin is moaning about it:
๏ Error 01:19:58 msg_show.lua_error Error executing vim.schedule lua callback: ...l/share/nvim/lazy/mason.nvim/lua/mason-registry/init.lua:78: Cannot find package "bashls".
stack traceback:
[C]: in function 'error'
...l/share/nvim/lazy/mason.nvim/lua/mason-registry/init.lua:78: in function 'get_package'
...on-tool-installer.nvim/lua/mason-tool-installer/init.lua:111: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
On the contrary, in the documentation of mason-lspconfig
setup the author of mason sincerely mentioned the importance of the ordering of the setup
-chains where you missed this part at all in your README:
It's important that you set up the plugins in the following order:
- mason.nvim
- mason-lspconfig.nvim
- Setup servers via lspconfig
Pay extra attention to this if you lazy-load plugins, or somehow "chain" the loading of plugins via your plugin manager.
require("mason").setup() require("mason-lspconfig").setup() -- After setting up mason-lspconfig you may set up servers via lspconfig -- require("lspconfig").lua_ls.setup {} -- require("lspconfig").rust_analyzer.setup {} -- ...
Compared to what you said:
You can use both.
You can use both. That is a correct statement. I don't happen to use both, but you can do it. "Using both" has nothing at all to do with ordering of plugins, or lazy loading, or what plugin installer you happen to use. These are orthogonal tasks.
As for the server names the README for mason-tool-installer
does say that the name of the thing to be installed should be the name mason
uses for that thing. i.e. use lua-language-server
, not lua_ls
. It is interesting that mason
seems to work with all of these names now as I don't believe it always has. I will make an issue to look into that. I'd be fine if mason-tool-installer
worked with all possible names. For now it doesn't.
I believe there may be a misunderstanding. mason-tool-installer
has nothing to do with mason-lspconfig
. This plugin is its own thing. mason-lspconfig
is not a dependency. This plugin is designed to automatically install anything that mason
can install regardless of whether it's an LSP server or something else.
This plugin is designed to automatically install anything that mason can [...]
FYI: currently there is an error when (auto-)installing cmake-language-server
:
๏ Info 02:55:01 notify.info [mason-tool-installer] cmake-language-server: updating to 0.1.6
๏ Error 02:55:04 notify.error [mason-tool-installer] cmake-language-server: failed to install
"Using both" has nothing at all to do with ordering of plugins [...]
But if you run require('mason-tool-installer').setup {...}
before the one of mason-lspconfig
then you will end up installing the same tool twice. I just tested it.
It is interesting that mason seems to work with all of these names now as I don't believe it always has.
Yes, the author made some updates months ago to fix the bug.
Why would you list the server you need in both mason-lspconfig
and mason-tool-installer
? That makes no sense. Don't do that.
This plugin is designed to automatically install anything that mason can install regardless of whether it's an LSP server or something else.
I think it's better to put this line (with some rewording for sure) in the README. Take my advice or not it's very unclear about what's the target of this plugin (many threads from the mason side mentioned your plugin because people want to ensure-install non-LSP tools). This is one of the reasons I call both setup
, but you're right that a server should be put in one place only. (Unfortunately at the time I was testing, your plugin only served as a plugin updater instead of a plugin installer.)
It is interesting that mason seems to work with all of these names now as I don't believe it always has. I will make an issue to look into that.
Thanks for taking care of this part. If those shorthands are soon to be deprecated then your way is actually better: the formal/specific names should be used. But as a new user of your plugin, I thought your plugin is out-of-date with mason and you didn't care about it. (as this issue was closed without any linked PR of any fix to help users to better understand your plugin.)