Disabling typescript-tools breaks LSP
Hi 👋
I'm facing some weird issue after rebasing my fork on top of your current (`main`)[https://github.com/Alexis12119/nvim-config/commit/f13124be53ebb8902eaf82a52083151341066c48].
I noticed that none of the LSP clients would start anymore.
Looking at LspLog, this is what I see for every single lsp client:
```
[ERROR][2025-04-15 17:18:54] .../lua/vim/lsp.lua:455 "cannot start ts_ls due to config error: .../Cellar/neovim/0.11.0/share/nvim/runtime/lua/vim/lsp.lua:444: cmd: expected expected function or table with executable command, got nil"
[ERROR][2025-04-15 17:18:54] .../lua/vim/lsp.lua:455 "cannot start vimls due to config error: .../Cellar/neovim/0.11.0/share/nvim/runtime/lua/vim/lsp.lua:444: cmd: expected expected function or table with executable command, got nil"
[ERROR][2025-04-15 17:18:54] .../lua/vim/lsp.lua:455 "cannot start yamlls due to config error: .../Cellar/neovim/0.11.0/share/nvim/runtime/lua/vim/lsp.lua:444: cmd: expected expected function or table with executable command, got nil"
[ERROR][2025-04-15 17:18:54] .../lua/vim/lsp.lua:455 "cannot start cssls due to config error: .../Cellar/neovim/0.11.0/share/nvim/runtime/lua/vim/lsp.lua:444: cmd: expected expected function or table with executable command, got nil"
...
```
Then I looked at LspInfo and noticed that a lot of defaults are missing (`cmd`, `filetypes`, `root_markers`, etc... basically anything that is not explicitly defined in an `lua/plugins/lsp/settings/<lang>.lua` file for a given lsp config or in `lua/plugins/lsp/opts.lua`, which defined `capabilities`, `on_attach` and `on_init` for all configs)
For example, this is the diff for `lua_ls` client from LspInfo:
```diff
--- orig.txt 2025-04-15 18:51:05.847563425 +0200
+++ mine.txt 2025-04-15 18:51:18.790307869 +0200
@@ -28,8 +28,11 @@
}
}
}
- - cmd: { "lua-language-server" }
- - filetypes: lua
- on_attach: <function @/Users/sergio/.config/nvim-orig/lua/plugins/lsp/opts.lua:44>
- on_init: <function @/Users/sergio/.config/nvim-orig/lua/plugins/lsp/opts.lua:49>
- - root_markers: .luarc.json, .luarc.jsonc, .luacheckrc, .stylua.toml, stylua.toml, selene.toml, selene.yml, .git
- settings: {
Lua = {
diagnostics = {
```
If I revert [this change](https://github.com/Alexis12119/nvim-config/commit/f13124be53ebb8902eaf82a52083151341066c48), particularly, use the old way via `require("lspconfig")[server_name].setup(opts)`:
```diff
diff --git a/lua/plugins/lsp/configs/mason.lua b/lua/plugins/lsp/configs/mason.lua
index 3d9b3b3..302bdb2 100644
--- a/lua/plugins/lsp/configs/mason.lua
+++ b/lua/plugins/lsp/configs/mason.lua
@@ -69,10 +69,10 @@ return {
end
-- Neovim < 0.11
- -- require("lspconfig")[server_name].setup(opts)
+ require("lspconfig")[server_name].setup(opts)
-- Neovim >= 0.11
- vim.lsp.config(server_name, opts)
- vim.lsp.enable(server_name)
+ -- vim.lsp.config(server_name, opts)
+ -- vim.lsp.enable(server_name)
end,
}
end,
```
then the LSP client is attached fine, but using `vim.lsp.config(server_name, opts)` + `vim.lsp.enable(server_name)` does not seem to work for me :/
Tried comparing the code, reverting some changes to make them same as your config, comparing some plugins versions... and I can't for the life of me figure out what's missing. Do you know by any chance where do these default come from? Is it some plugin or something else? It should be from `nvim-lspconfig`, right? But I don't get why it's not picked up properly.
关闭于 2025-04-17 7 条评论