diff --git a/README.md b/README.md index 0ffcc4de..ec88ccdd 100644 --- a/README.md +++ b/README.md @@ -124,9 +124,12 @@ require("codecompanion").setup({ width = 95, height = 10, }, + advisor = { + stream = false, -- Stream the output like a chat buffer? + }, chat = { -- Options for the chat strategy type = "float", -- float|buffer - show_settings = false, -- Show the model settings in the chat window + show_settings = false, -- Show the model settings in the chat window? show_token_count = true, -- Show the token count for the current chat? buf_options = { -- Buffer options for the chat buffer buflisted = false, diff --git a/lua/codecompanion/config.lua b/lua/codecompanion/config.lua index 654cfb51..6a754ed9 100644 --- a/lua/codecompanion/config.lua +++ b/lua/codecompanion/config.lua @@ -27,6 +27,9 @@ local defaults = { width = 95, height = 10, }, + advisor = { + stream = false, + }, chat = { type = "float", show_settings = false, diff --git a/lua/codecompanion/strategy/advisor.lua b/lua/codecompanion/strategy/advisor.lua index 4c3bf2b7..11e0236a 100644 --- a/lua/codecompanion/strategy/advisor.lua +++ b/lua/codecompanion/strategy/advisor.lua @@ -74,13 +74,24 @@ function Advisor:execute(user_input) }) end + local messages = conversation.messages + + if config.options.display.advisor.stream then + local chat = require("codecompanion.strategy.chat").new({ + client = self.client, + messages = messages, + show_buffer = true, + }) + + return chat:submit() + end + self.client:advisor(conversation, function(err, data) if err then log:error("Advisor Error: %s", err) vim.notify(err, vim.log.levels.ERROR) end - local messages = conversation.messages table.insert(messages, data.choices[1].message) table.insert(messages, { role = "user",