Closed Arjun31415 closed 1 year ago
Not much to add except that it seems to apply to all language servers, these are from my log
[ERROR Mon 13 Mar 2023 09:28:47 AM CET] ...pack/packer/start/mason.nvim/lua/mason-registry/init.lua:77: Cannot find package "\"pyright\"".
[ERROR Mon 13 Mar 2023 09:28:47 AM CET] ...pack/packer/start/mason.nvim/lua/mason-registry/init.lua:77: Cannot find package "\"lua-language-server\"".
[ERROR Mon 13 Mar 2023 09:28:47 AM CET] ...pack/packer/start/mason.nvim/lua/mason-registry/init.lua:77: Cannot find package "\"json-lsp\"".
[ERROR Mon 13 Mar 2023 09:28:47 AM CET] ...pack/packer/start/mason.nvim/lua/mason-registry/init.lua:77: Cannot find package "\"yaml-language-server\"".
[ERROR Mon 13 Mar 2023 09:28:47 AM CET] ...pack/packer/start/mason.nvim/lua/mason-registry/init.lua:77: Cannot find package "\"taplo\"".
[ERROR Mon 13 Mar 2023 09:28:47 AM CET] ...pack/packer/start/mason.nvim/lua/mason-registry/init.lua:77: Cannot find package "\"eslint-lsp\"".
[ERROR Mon 13 Mar 2023 09:28:47 AM CET] ...pack/packer/start/mason.nvim/lua/mason-registry/init.lua:77: Cannot find package "\"omnisharp\"".```
Yeah same here, it seems if we have lsp-install installed then it expects the names used in lsp-install and it is not the same as the the name when we install it from mason, it is a pain to find the name lsp-install expects as well.
Make sure to set up mason.nvim
before any dependents. The reason packages aren't found is because Mason hasn't been set up yet (this used to however work until recently, but it wasn't intended or supported)
Yeah it is fixed by doing above mentioned change. Thank you
In my case it wasn't quite that simple. I am sure this results in a configuration where somehow mason-lspconfig setup gets called early, but I couldn't say why. This is the packer definition for mason I had.
return {
{
'williamboman/mason.nvim',
config = function()
require('mason').setup()
end,
},
{
'williamboman/mason-lspconfig.nvim',
requires = {
'neovim/nvim-lspconfig',
'williamboman/mason.nvim',
},
config = function()
require('mason-lspconfig').setup({
ensure_installed = {
'tsserver',
'pyright',
'lua_ls',
'jsonls',
'yamlls',
'taplo',
'eslint',
'omnisharp',
},
})
end,
},
{
'WhoIsSethDaniel/mason-tool-installer.nvim',
requires = {
'williamboman/mason.nvim',
},
config = function()
require('mason-tool-installer').setup({
ensure_installed = {
'prettierd',
'black',
'isort',
'cspell',
'stylua',
'debugpy',
},
})
end,
},
}
Removing neovim/nvim-lspconfig
from the mason-lspconfig
requirements fixes the problem for me. The nvim-lspconfig
definition doesn't mention mason at all. I have no idea why it was in there though as it doesn't make sense to require nvim-lspconfig before the necessary lsp servers are installed by mason.
I have the same problem with mypy
, I am using:
return {
"williamboman/mason.nvim",
dependencies = {
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
},
config = function()
-- import mason
local mason = require("mason")
-- import mason-lspconfig
local mason_lspconfig = require("mason-lspconfig")
local mason_tool_installer = require("mason-tool-installer")
-- enable mason and configure icons
mason.setup({
ui = {
icons = {
package_installed = "✓",
package_pending = "➜",
package_uninstalled = "✗",
},
},
})
mason_lspconfig.setup({
-- list of servers for mason to install
ensure_installed = {
"lua_ls",
"mypy",
"clangd",
"ltex",
"bashls",
"jsonls",
},
})
mason_tool_installer.setup({
ensure_installed = {
"prettier", -- prettier formatter
"stylua", -- lua formatter
"isort", -- python formatter
"pylint",
},
})
end,
I've searched open issues for similar requests
Yes
I've recently downloaded the latest plugin version of mason.nvim
Problem description
ensure installed option on
mason-lspconfig
results in errorExpected behavior
ensure installed at least does not throw an error
Affected packages
All (not sure because it is something to do with registry)
Mason output
Installation log
Neovim version (>= 0.7)
NVIM v0.9.0-dev-1187+g845efb8e1 Build type: Release LuaJIT 2.1.0-beta3
Operating system/version
Healthcheck
Screenshots