plugins.copilot-chat.settings

Options provided to the require('copilot-chat').setup function.

Type: attribute set of anything

Default: { }

Example:

{
  answer_header = "## Copilot ";
  auto_follow_cursor = false;
  error_header = "## Error ";
  mappings = {
    close = {
      insert = "<C-c>";
      normal = "q";
    };
    complete = {
      detail = "Use @<Tab> or /<Tab> for options.";
      insert = "<Tab>";
    };
  };
  prompts = {
    Explain = "Please explain how the following code works.";
    Review = "Please review the following code and provide suggestions for improvement.";
    Tests = "Please explain how the selected code works, then generate unit tests for it.";
  };
  question_header = "## User ";
  show_help = false;
}

Declared by:

plugins.copilot-chat.settings.allow_insecure

Allow insecure server connections.

Plugin default: false

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.answer_header

Header to use for AI answers.

Plugin default: "## Copilot "

Type: null or string or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.auto_follow_cursor

Auto-follow cursor in chat.

Plugin default: true

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.auto_insert_mode

Automatically enter insert mode when opening window and if auto follow cursor is enabled on new prompt.

Plugin default: false

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.callback

Callback to use when ask response is received.

fun(response: string, source: CopilotChat.config.source)

Plugin default: null

Type: null or lua function string

Default: null

Declared by:

plugins.copilot-chat.settings.clear_chat_on_new_prompt

Clears chat on every new prompt.

Plugin default: false

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.context

Default context to use, "buffers", "buffer" or null (can be specified manually in prompt via @).

Plugin default: null

Type: null or one of “buffers”, “buffer” or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.debug

Enable debug logging.

Plugin default: false

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.error_header

Header to use for errors.

Plugin default: "## Error "

Type: null or string or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.highlight_selection

Highlight selection.

Plugin default: true

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.history_path

Default path to stored history.

Plugin default:

{
  __raw = "vim.fn.stdpath('data') .. '/copilotchat_history'";
}

Type: null or string or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.mappings

Mappings for CopilotChat.

Plugin default:

{
  accept_diff = {
    insert = "<C-y>";
    normal = "<C-y>";
  };
  close = {
    insert = "<C-c>";
    normal = "q";
  };
  complete = {
    detail = "Use @<Tab> or /<Tab> for options.";
    insert = "<Tab>";
  };
  reset = {
    insert = "<C-l>";
    normal = "<C-l>";
  };
  show_diff = {
    normal = "gd";
  };
  show_system_prompt = {
    normal = "gp";
  };
  show_user_selection = {
    normal = "gs";
  };
  submit_prompt = {
    insert = "<C-m>";
    normal = "<CR>";
  };
  yank_diff = {
    normal = "gy";
  };
}

Type: null or (attribute set of ((submodule) or raw lua code))

Default: null

Declared by:

plugins.copilot-chat.settings.model

GPT model to use, ‘gpt-3.5-turbo’ or ‘gpt-4’.

Plugin default: "gpt-4"

Type: null or string or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.prompts

Default prompts.

Plugin default:

{
  Commit = {
    prompt = "Write commit message for the change with commitizen convention. Make sure the title has maximum 50 characters and message is wrapped at 72 characters. Wrap the whole message in code block with language gitcommit.";
    selection = "require('CopilotChat.select').gitdiff";
  };
  CommitStaged = {
    prompt = "Write commit message for the change with commitizen convention. Make sure the title has maximum 50 characters and message is wrapped at 72 characters. Wrap the whole message in code block with language gitcommit.";
    selection = ''
      function(source)
        return select.gitdiff(source, true)
      end
    '';
  };
  Docs = {
    prompt = "/COPILOT_GENERATE Please add documentation comment for the selection.";
  };
  Explain = {
    prompt = "/COPILOT_EXPLAIN Write an explanation for the active selection as paragraphs of text.";
  };
  Fix = {
    prompt = "/COPILOT_GENERATE There is a problem in this code. Rewrite the code to show it with the bug fixed.";
  };
  FixDiagnostic = {
    prompt = "Please assist with the following diagnostic issue in file:";
    selection = "require('CopilotChat.select').diagnostics";
  };
  Optimize = {
    prompt = "/COPILOT_GENERATE Optimize the selected code to improve performance and readablilty.";
  };
  Review = {
    callback = ''
      function(response, source)
        -- see config.lua for implementation
      end
    '';
    prompt = "/COPILOT_REVIEW Review the selected code.";
  };
  Tests = {
    prompt = "/COPILOT_GENERATE Please generate tests for my code.";
  };
}

Type: null or (attribute set of (string or (attribute set of anything) or raw lua code))

Default: null

Declared by:

plugins.copilot-chat.settings.proxy

Custom proxy to use, formatted as [protocol://]host[:port].

Plugin default: null

Type: null or string or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.question_header

Header to use for user questions.

Plugin default: "## User "

Type: null or string or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.selection

Default selection (visual or line). fun(source: CopilotChat.config.source):CopilotChat.config.selection

Plugin default:

function(source)
  local select = require('CopilotChat.select')
  return select.visual(source) or select.line(source)
end

Type: null or lua function string

Default: null

Declared by:

plugins.copilot-chat.settings.separator

Separator to use in chat.

Plugin default: "───"

Type: null or string or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.show_folds

Shows folds for sections in chat.

Plugin default: true

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.show_help

Shows help message as virtual lines when waiting for user input.

Plugin default: true

Type: null or boolean or raw lua code

Default: null

Declared by:

plugins.copilot-chat.settings.system_prompt

System prompt to use.

Plugin default: require('CopilotChat.prompts').COPILOT_INSTRUCTIONS

Type: null or lua code string

Default: null

Declared by:

plugins.copilot-chat.settings.temperature

GPT temperature.

Plugin default: 0.1

Type: null or integer or floating point number between 0.0 and 1.0 (both inclusive) or raw lua code

Default: null

Declared by: