Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ return {
},
opts = {
debug = true, -- Enable debugging
-- language = "English" -- Copilot answer language settings when using default prompts. Default language is English.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this, add the default config part to default config section (e.g just mirror the change in config.lua)

-- See Configuration section for rest
},
-- See Commands section for default commands if you want to lazy load on them
Expand Down
2 changes: 2 additions & 0 deletions lua/CopilotChat/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ local select = require('CopilotChat.select')
---@field proxy string?
---@field allow_insecure boolean?
---@field debug boolean?
---@field language string?
---@field show_user_selection boolean?
---@field show_system_prompt boolean?
---@field show_folds boolean?
Expand All @@ -76,6 +77,7 @@ return {
auto_follow_cursor = true, -- Auto-follow cursor in chat
name = 'CopilotChat', -- Name to use in chat
separator = '---', -- Separator to use in chat
language = nil, -- Copilot answer language settings when using default prompts. Default language is English.
-- default prompts
prompts = {
Explain = {
Expand Down
13 changes: 13 additions & 0 deletions lua/CopilotChat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,23 @@ function M.debug(debug)
log.logfile = logfile
end

--- Set up the language for default prompts
---@param config CopilotChat.config|nil
function M.setup_copilot_language(config)
if not config or not config.language then
return
end

for _, prompt in pairs(config.prompts) do
prompt.prompt = prompt.prompt .. ' ' .. prompts.PROMPT_ANSWER_LANGUAGE_TEMPLATE(config.language)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not edit config, see how updating prompt is handled elsewhere.

end
end

--- Set up the plugin
---@param config CopilotChat.config|nil
function M.setup(config)
M.config = vim.tbl_deep_extend('force', default_config, config or {})
M.setup_copilot_language(M.config)
state.copilot = Copilot(M.config.proxy, M.config.allow_insecure)

state.diff = Diff(
Expand Down
6 changes: 6 additions & 0 deletions lua/CopilotChat/prompts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,10 @@ M.SHOW_CONTEXT = [[
At the beginning of your response show code outline from all the provided files coming from Context and Active Selection.
]]

---Prompt for the user to provide a language
--- @param language string
function M.PROMPT_ANSWER_LANGUAGE_TEMPLATE(language)

@deathbeam deathbeam Mar 16, 2024

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be in prompts file anymore. Now its used for populating prompts whn completing automatically so if this isnt part of it it should not be here

return string.format([[Please answer in %s.]], language)
end

return M