-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: properly track library usage per workspace folder
- Loading branch information
Showing
5 changed files
with
222 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local Config = require("lazydev.config") | ||
local Workspace = require("lazydev.workspace") | ||
|
||
local M = {} | ||
M.attached = {} ---@type table<number,number> | ||
|
||
---@param client vim.lsp.Client | ||
function M.attach(client) | ||
if M.attached[client.id] then | ||
return | ||
end | ||
M.attached[client.id] = client.id | ||
---@param params lsp.ConfigurationParams | ||
client.handlers["workspace/configuration"] = function(err, params, ctx, cfg) | ||
if not params.items then | ||
return {} | ||
end | ||
|
||
local response = {} | ||
for _, item in ipairs(params.items) do | ||
if item.section then | ||
local settings = client.settings | ||
if item.scopeUri and item.section == "Lua" then | ||
local root = vim.uri_to_fname(item.scopeUri) | ||
if Config.is_enabled(root) then | ||
local ws = Workspace.get(client, root) | ||
settings = ws.settings | ||
if Config.debug then | ||
ws:debug() | ||
end | ||
end | ||
end | ||
|
||
local keys = vim.split(item.section, ".", { plain = true }) --- @type string[] | ||
local value = vim.tbl_get(settings, unpack(keys)) | ||
-- For empty sections with no explicit '' key, return settings as is | ||
if value == nil and item.section == "" then | ||
value = client.settings | ||
end | ||
if value == nil then | ||
value = vim.NIL | ||
end | ||
table.insert(response, value) | ||
end | ||
end | ||
return response | ||
end | ||
end | ||
|
||
function M.update(client) | ||
client.notify("workspace/didChangeConfiguration", { | ||
settings = { Lua = {} }, | ||
}) | ||
end | ||
|
||
return M |
Oops, something went wrong.