Skip to content

Commit

Permalink
perf: dont return workspace library for the fallback scope
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 2, 2024
1 parent 7d843b9 commit 2e715cd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lua/lazydev/buf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ function M.on_require(modname)
end
end

---@param client vim.lsp.Client
function M.set_handlers(client)
client.handlers["workspace/configuration"] = client.handlers["workspace/configuration"]
---@param params lsp.ConfigurationParams
or function(err, params, ctx, cfg)
---@type any[]
local ret = vim.deepcopy(vim.lsp.handlers["workspace/configuration"](err, params, ctx, cfg))
-- Don't set workspace libraries for the fallback scope
for i, item in ipairs(params.items) do
if item.section == "Lua" and not item.scopeUri and type(ret[i]) == "table" and ret[i].workspace then
ret[i].workspace.library = nil
end
end
return ret
end
end

--- Update LuaLS settings with the current library
function M.update()
if package.loaded["neodev"] then
Expand All @@ -138,6 +155,7 @@ function M.update()
)
end
for _, client in ipairs(M.get_clients()) do
M.set_handlers(client)
local settings = vim.deepcopy(client.settings or {})

---@type string[]
Expand Down

0 comments on commit 2e715cd

Please sign in to comment.