Open qujihan opened 1 year ago
Hey! This is probably happening because the config
hook for lspconfig executes before Mason. You need to ensure that Mason is set up before lspconfig.
I had the same issue with rust-analyzer
, and I figured out that mason
installs binary packages and put a wrapper shell script into a single bin
directory, in this way it would only need to add one entry to the PATH
environment variable. in my case, it is named rust-analyzer.cmd
. this is usually fine, so long you run this command through a shell, as the .cmd
suffix is recognized by the Windows shell. e.g. :lua =vim.fn.system 'rust-analyzer --version'
would give me the correct version, and I can type rust-analyzer --version
directly into a nvim terminal too. I guess the lsp integration somehow trys to spawn a process directly from this command name, which it can't and hence the error.
in my case, I solved it by manually set the server cmd like so:
-- pass nil will use default setting
local cmd = nil
if jit.os == 'Windows' then
cmd = { 'cmd.exe', '/c', 'rust-analyzer' }
end
require 'lspconfig'.rust_analyzer.setup {
cmd = cmd,
}
ps1: my lua_ls
works out of the box, but rust-analyzer
doesn't
ps1: I am not sure my problem is caused by setup order, as I have my setup code explictly specifying mason-lspconfig
should load after mason.nvim
:
packer.use {
'williamboman/mason.nvim' ,
config = function() require 'mason'.setup {} end,
}
packer.use {
'williamboman/mason-lspconfig.nvim',
requires = { 'williamboman/mason.nvim', 'neovim/nvim-lspconfig', },
after = { 'mason.nvim', },
config = function() require 'mason-lspconfig'setup {} end,
}
packer.use {
'neovim/nvim-lspconfig',
after = { 'mason-lspconfig.nvim', },
config = function()
local lsconfig = require 'lspconfig'
-- server settings omitted
end,
}
I got some error like this
Spawning language server with cmd: /data/data/com.termux/files/home/.local/share/nvim/mason/bin/intelephense
failed. The language server is either not installed, missing from PATH, or not executable.
I use AstroNvim, it works on Linux Ubuntu, but it doesn't work Termux(latest build, android 14), if I run $ intelphense
it show the script and I think it executable
So how to fix it?
Problem description
Spawning language server with cmd:
clangd
failed. The language server is either not installed, missing from PATH, or not executable. The same configuration works fine under ArchLinux(wsl), but not under WindowsWhy do you think this is an issue with mason-lspconfig.nvim?
I'm not sure if it's Mason's problem, but I wondered if there was a problem with the download
Neovim version (>= 0.7)
windows:NVIM v0.8.2 archlinux(wsl):NVIM v0.8.2
Operating system/version
windows:windows 11 /archlinux :Linux 9a3b81476179 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 GNU/Linux
I've manually reviewed the Nvim LPS client log (
:LspLog
) to find potential errorsI've recently downloaded the latest plugin version of mason.nvim, mason-lspconfig.nvim, and nvim-lspconfig
Affected language servers
clangd
Steps to reproduce
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release lazypath, }) end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup( { { "williamboman/mason.nvim", config = function() require("mason").setup {} end }, { "williamboman/mason-lspconfig.nvim", config = function() require("mason-lspconfig").setup { ensure_installed = { "clangd" }, automatic_installation = true, } end }, { "neovim/nvim-lspconfig", config = function() require("lspconfig")['clangd'].setup {} end }, } )
LspLog
No response
Healthcheck
Screenshots or recordings
No response