Skip to content
This repository was archived by the owner on Jul 6, 2024. It is now read-only.

Commit c6be05a

Browse files
committed
perf(luals): don't add workspace library for the fallback scope
1 parent 3941036 commit c6be05a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lua/neodev/lsp.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ function M.on_new_config(config, root_dir)
7777
and config.settings.Lua.workspace.ignoreDir
7878
or {}
7979

80+
config.handlers = config.handlers or {}
81+
config.handlers["workspace/configuration"] = config.handlers["workspace/configuration"]
82+
or function(err, result, ctx, cfg)
83+
local ret = vim.lsp.handlers["workspace/configuration"](err, result, ctx, cfg)
84+
-- when scopeUri is not set, then the requested config is for the fallback scope
85+
-- Don't set workspace libraries for the fallback scope
86+
-- Thanks to: https://github.com/LuaLS/lua-language-server/issues/1596#issuecomment-1855087288
87+
for i, item in ipairs(result.items) do
88+
if type(ret[i]) == "table" then
89+
if not item.scopeUri and ret[i].workspace then
90+
ret[i].workspace.library = nil
91+
end
92+
end
93+
end
94+
return ret
95+
end
96+
8097
if opts.library.enabled then
8198
config.settings =
8299
vim.tbl_deep_extend("force", config.settings or {}, require("neodev.luals").setup(opts, config.settings).settings)

0 commit comments

Comments
 (0)