Skip to content

Commit 8b58670

Browse files
authored
fix(init): simplify lazy initialization logic (#1549)
Refactors the lazy initialization in the CopilotChat main module to call the setup function directly and set the 'initialized' flag before invocation. Removes the pcall error handling and logging, as setup should not fail silently. This makes the initialization logic clearer and more predictable.
1 parent 969c220 commit 8b58670

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

lua/CopilotChat/init.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ local M = setmetatable({}, {
2222
-- Lazy initialize
2323
local initialized = rawget(t, 'initialized')
2424
if not initialized then
25-
local ok, err = pcall(rawget(t, 'setup'))
26-
if ok then
27-
rawset(t, 'initialized', true)
28-
else
29-
require('plenary.log').error('CopilotChat setup failed:', err)
30-
end
25+
rawset(t, 'initialized', true)
26+
rawget(t, 'setup')()
3127
end
3228

3329
return rawget(t, key)

0 commit comments

Comments
 (0)