Skip to content

Commit f31a79f

Browse files
authored
fix: LSP start logic (#1496)
* Revert "fix: remove manual `LspStart`, close #1478. (#1479)" This reverts commit 7dab4b9. * Revert "fixup(#1466): load lsp config with proper event. (#1472)" This reverts commit 53eeeec. * fix: LSP start logic This should acc fix #1472 and #1479 cuz iirc the root cause was that lspconfig changed how `LspStart` works. Now it only starts one _specific_ server (passed via the first argument), instead of starting all matching servers automatically. So we gotta manually start all the servers that match the current filetype instead. Signed-off-by: Jint-lzxy <[email protected]> --------- Signed-off-by: Jint-lzxy <[email protected]>
1 parent 80bc15f commit f31a79f

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

lua/modules/configs/completion/lsp.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ return function()
1818
end
1919

2020
pcall(require, "user.configs.lsp")
21+
22+
-- Start LSPs
23+
pcall(function()
24+
local matching_configs = nvim_lsp.util.get_config_by_ft(vim.bo.filetype)
25+
for _, config in ipairs(matching_configs) do
26+
config.launch()
27+
end
28+
end)
2129
end

lua/modules/configs/completion/mason-lspconfig.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
8181
{ title = "nvim-lspconfig" }
8282
)
8383
end
84+
return
8485
end
8586

8687
for _, lsp in ipairs(lsp_deps) do

lua/modules/configs/editor/persisted.lua

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
return function()
2-
vim.api.nvim_create_autocmd("User", {
3-
pattern = "PersistedLoadPost",
4-
desc = "Fix LSP/Highlighting on auto session restore",
5-
callback = function()
6-
local bufname = vim.api.nvim_buf_get_name(0)
7-
if bufname and bufname ~= "" then
8-
vim.defer_fn(function()
9-
vim.cmd("edit")
10-
end, 1)
11-
end
12-
end,
13-
})
142
require("modules.utils").load_plugin("persisted", {
153
save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"),
164
autostart = true,

lua/modules/plugins/completion.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local completion = {}
22

33
completion["neovim/nvim-lspconfig"] = {
44
lazy = true,
5-
event = { "BufReadPre", "BufNewFile" },
5+
event = { "CursorHold", "CursorHoldI" },
66
config = require("completion.lsp"),
77
dependencies = {
88
{ "mason-org/mason.nvim" },

0 commit comments

Comments
 (0)