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.

Type: null or boolean or raw lua code

Default: null

Plugin default: false

Declared by:

plugins.copilot-chat.settings.answer_header

Header to use for AI answers.

Type: null or string or raw lua code

Default: null

Plugin default: "## Copilot "

Declared by:

plugins.copilot-chat.settings.auto_follow_cursor

Auto-follow cursor in chat.

Type: null or boolean or raw lua code

Default: null

Plugin default: true

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.

Type: null or boolean or raw lua code

Default: null

Plugin default: false

Declared by:

plugins.copilot-chat.settings.callback

Callback to use when ask response is received.

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

Type: null or lua function string

Default: null

Plugin default: null

Declared by:

plugins.copilot-chat.settings.clear_chat_on_new_prompt

Clears chat on every new prompt.

Type: null or boolean or raw lua code

Default: null

Plugin default: false

Declared by:

plugins.copilot-chat.settings.context

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

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

Default: null

Plugin default: null

Declared by:

plugins.copilot-chat.settings.debug

Enable debug logging.

Type: null or boolean or raw lua code

Default: null

Plugin default: false

Declared by:

plugins.copilot-chat.settings.error_header

Header to use for errors.

Type: null or string or raw lua code

Default: null

Plugin default: "## Error "

Declared by:

plugins.copilot-chat.settings.highlight_selection

Highlight selection.

Type: null or boolean or raw lua code

Default: null

Plugin default: true

Declared by:

plugins.copilot-chat.settings.history_path

Default path to stored history.

Type: null or string or raw lua code

Default: null

Plugin default:

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

Declared by:

plugins.copilot-chat.settings.mappings

Mappings for CopilotChat.

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

Default: null

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";
  };
}

Declared by:

plugins.copilot-chat.settings.model

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

Type: null or string or raw lua code

Default: null

Plugin default: "gpt-4"

Declared by:

plugins.copilot-chat.settings.prompts

Default prompts.

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

Default: null

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.";
  };
}

Declared by:

plugins.copilot-chat.settings.proxy

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

Type: null or string or raw lua code

Default: null

Plugin default: null

Declared by:

plugins.copilot-chat.settings.question_header

Header to use for user questions.

Type: null or string or raw lua code

Default: null

Plugin default: "## User "

Declared by:

plugins.copilot-chat.settings.selection

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

Type: null or lua function string

Default: null

Plugin default:

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

Declared by:

plugins.copilot-chat.settings.separator

Separator to use in chat.

Type: null or string or raw lua code

Default: null

Plugin default: "───"

Declared by:

plugins.copilot-chat.settings.show_folds

Shows folds for sections in chat.

Type: null or boolean or raw lua code

Default: null

Plugin default: true

Declared by:

plugins.copilot-chat.settings.show_help

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

Type: null or boolean or raw lua code

Default: null

Plugin default: true

Declared by:

plugins.copilot-chat.settings.system_prompt

System prompt to use.

Type: null or lua code string

Default: null

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

Declared by:

plugins.copilot-chat.settings.temperature

GPT temperature.

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

Default: null

Plugin default: 0.1

Declared by: