Skip to content

Commit

Permalink
fix(cmd): strategy now respects vim.g.codecompanion_adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
olimorris committed Dec 9, 2024
1 parent 02c1bc0 commit b629005
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lua/codecompanion/strategies/chat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,7 @@ function Chat:submit(opts)

self:apply_tools_and_variables(message)

-- Check if the user has manually overriden the adapter. This is useful if the
-- user loses their internet connection and wants to switch to a local LLM
-- Check if the user has manually overriden the adapter
if vim.g.codecompanion_adapter and self.adapter.name ~= vim.g.codecompanion_adapter then
self.adapter = adapters.resolve(config.adapters[vim.g.codecompanion_adapter])
end
Expand Down
5 changes: 5 additions & 0 deletions lua/codecompanion/strategies/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ function Cmd.new(args)
return log:error("No adapter found")
end

-- Check if the user has manually overriden the adapter
if vim.g.codecompanion_adapter and self.adapter.name ~= vim.g.codecompanion_adapter then
self.adapter = adapters.resolve(config.adapters[vim.g.codecompanion_adapter])
end

return self
end

Expand Down
3 changes: 1 addition & 2 deletions lua/codecompanion/strategies/inline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ function Inline.new(args)
return log:error("No adapter found")
end

-- Check if the user has manually overriden the adapter. This is useful if the
-- user loses their internet connection and wants to switch to a local LLM
-- Check if the user has manually overriden the adapter
if vim.g.codecompanion_adapter and self.adapter.name ~= vim.g.codecompanion_adapter then
self.adapter = adapters.resolve(config.adapters[vim.g.codecompanion_adapter])
end
Expand Down

0 comments on commit b629005

Please sign in to comment.