Skip to content

Commit 33c6cf5

Browse files
committed
refactor codecompanion plugin OAuth and adapter setup
- Remove return of OAuth token from validate_oauth_setup, returning only validation status - Refactor adapter initialization to conditionally set adapters only if OAuth setup is valid - Move require("codecompanion").setup call outside validation block and pass adapters accordingly
1 parent 6402c39 commit 33c6cf5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

config/lua/plugins/codecompanion.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ return {
2121
end
2222

2323
vim.notify("✓ Claude OAuth token configured", vim.log.levels.INFO)
24-
return true, oauth_token
24+
return true
2525
end
2626

2727
-- Helper function to keep only allowed message fields
@@ -130,12 +130,10 @@ return {
130130
end
131131

132132
-- Validate setup and get OAuth token
133-
local is_valid, oauth_token = validate_oauth_setup()
134-
if not is_valid then
135-
return -- Don't proceed with setup if token is missing
136-
end
133+
local is_valid = validate_oauth_setup()
137134

138-
require("codecompanion").setup({
135+
local adapters = {}
136+
if is_valid then
139137
adapters = {
140138
anthropic = function()
141139
local utils = require("codecompanion.utils.adapters")
@@ -280,7 +278,11 @@ return {
280278
},
281279
})
282280
end,
283-
},
281+
}
282+
end
283+
284+
require("codecompanion").setup({
285+
adapters = adapters,
284286
extensions = {
285287
mcphub = {
286288
callback = "mcphub.extensions.codecompanion",

0 commit comments

Comments
 (0)