Skip to content
Merged
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 @@ -36,6 +36,7 @@ return {
show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes
debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log
disable_extra_info = 'no', -- Disable extra information (e.g: system prompt) in the response.
language = "English" -- Copilot answer language settings when using default prompts. Default language is English.
-- proxy = "socks5://127.0.0.1:3000", -- Proxies requests via https or socks.
},
build = function()
Expand Down
2 changes: 2 additions & 0 deletions lua/CopilotChat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ _COPILOT_CHAT_GLOBAL_CONFIG = {}
-- - disable_extra_info: ('yes' | 'no') default: 'yes'.
-- - hide_system_prompt: ('yes' | 'no') default: 'yes'.
-- - proxy: (string?) default: ''.
-- - language: (string?) default: ''.
-- - prompts: (table?) default: default_prompts.
-- - debug: (boolean?) default: false.
M.setup = function(options)
vim.g.copilot_chat_show_help = options and options.show_help or 'yes'
vim.g.copilot_chat_disable_separators = options and options.disable_extra_info or 'yes'
vim.g.copilot_chat_hide_system_prompt = options and options.hide_system_prompt or 'yes'
vim.g.copilot_chat_proxy = options and options.proxy or ''
vim.g.copilot_chat_language = options and options.language or ''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add to the document to README and before setup function? Thanks @neutrinoA4

local debug = options and options.debug or false
_COPILOT_CHAT_GLOBAL_CONFIG.debug = debug

Expand Down
3 changes: 3 additions & 0 deletions rplugin/python3/CopilotChat/handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self, nvim: MyNvim, buffer: MyBuffer):
self.copilot: Copilot = None
self.buffer: MyBuffer = buffer
self.proxy: str = os.getenv("HTTPS_PROXY") or os.getenv("ALL_PROXY") or ""
self.language = self.nvim.eval("g:copilot_chat_language")

# public

Expand Down Expand Up @@ -79,6 +80,8 @@ def _construct_system_prompt(self, prompt: str):
system_prompt = system_prompts.COPILOT_TESTS
elif prompt == system_prompts.EXPLAIN_SHORTCUT:
system_prompt = system_prompts.COPILOT_EXPLAIN
if self.language != "":
system_prompt = system_prompt + "\n" + system_prompts.PROMPT_ANSWER_LANGUAGE_TEMPLATE.substitute(language=self.language)
return system_prompt

def _add_start_separator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, nvim: MyNvim):
self.diff_mode: bool = False
self.model: str = MODEL_GPT4
self.system_prompt: str = "SENIOR_DEVELOPER_PROMPT"
self.language = self.nvim.eval("g:copilot_chat_language")

# Add user prompts collection
self.user_prompts = self.nvim.eval("g:copilot_chat_user_prompts")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, nvim: MyNvim):
"filetype": "copilot-chat",
},
)
self.language = self.nvim.eval("g:copilot_chat_language")

def vsplit(self):
self.buffer.option("filetype", "copilot-chat")
Expand Down
3 changes: 3 additions & 0 deletions rplugin/python3/CopilotChat/prompts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from string import Template

# pylint: disable=locally-disabled, multiple-statements, fixme, line-too-long
COPILOT_INSTRUCTIONS = """You are an AI programming assistant.
When asked for you name, you must respond with "GitHub Copilot".
Expand Down Expand Up @@ -249,3 +251,4 @@
"""
PROMPT_SIMPLE_DOCSTRING = "add simple docstring to this code"
PROMPT_SEPARATE = "add comments separating the code into sections"
PROMPT_ANSWER_LANGUAGE_TEMPLATE = Template("Please answer in ${language}")