Skip to content

Commit 3e75599

Browse files
committed
perf: optimize on_attach conditional checks
1 parent 0e224f3 commit 3e75599

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lua/astrolsp/init.lua

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ end
2525
---@param client lsp.Client
2626
---@param bufnr integer
2727
local function check_cond(cond, client, bufnr)
28-
local active = true
29-
if type(cond) == "function" then
30-
active = cond(client, bufnr)
31-
elseif type(cond) == "string" then
32-
active = client.supports_method(cond)
33-
elseif type(cond) == "boolean" then
34-
active = cond
35-
end
36-
return active
28+
local cond_type = type(cond)
29+
if cond_type == "function" then return cond(client, bufnr) end
30+
if cond_type == "string" then return client.supports_method(cond) end
31+
if cond_type == "boolean" then return cond end
32+
return true
3733
end
3834

3935
--- A table of settings for different levels of diagnostics

0 commit comments

Comments
 (0)