Mason bashls

备注

本文实践接 NeoVim IDE ,相关配置在 NeoVim IDE 中已基本完成,这里主要记录如何解决 Bash LSP 配置问题

我在 NeoVim IDE 实践中,配置 ~/.config/nvim/lua/lsp.lua 中添加了 "pylsp", "lua_ls", "bashls" 这3个LSP:

但是发现执行 nvim 进入dashboard时候,状态栏提示:

[mason-lspconfig.nvim] failed to install bashls. Installation logs are available in :Mason and :MasonLog
  • 执行 :Mason 可以看到,确实:

检查 :Mason 可以看到正确安装了 luapython LSP,没有看到 bash LSP
~                      Installed (2)
~                        ✓ lua-language-server lua_ls
~                        ✓ python-lsp-server pylsp
  • 执行 :MasonLog 检查日志发现,原来 bashls 依赖 npm ,所以采用 Node.js开发环境 部署:

安装nvm
# 安装nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm安装node.js
# 下载和安装Nodes.js,安装current版本,指定22
npm install 22

# 如果要安装LTS稳定完本,则指定20
npm install 20

然后再次启动 nvim 就可以通过 :Mason 观察到自动安装了 bash-language-server bashls

备注

基本上安装 Moson 的LSP 都是自动完成的,只不过不同的LSP可能会依赖一些操作系统工具来完成下载或运行。例如安装 clangd 就需要操纵系统安装了 unzip 工具。具体排查都可以让通过 :MasonLog 查看报错信息来获得对应解决方法