forked from CopilotC-Nvim/CopilotChat.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
39 lines (31 loc) · 1.25 KB
/
Copy pathinit.lua
File metadata and controls
39 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local utils = require('CopilotChat.utils')
local M = {}
local default_prompts = {
Explain = 'Explain how it works.',
Tests = 'Briefly how selected code works then generate unit tests.',
}
_COPILOT_CHAT_GLOBAL_CONFIG = {}
-- Set up the plugin
---@param options (table | nil)
-- - show_help: ('yes' | 'no') default: 'yes'.
-- - 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'
local debug = options and options.debug or false
_COPILOT_CHAT_GLOBAL_CONFIG.debug = debug
-- Merge the provided prompts with the default prompts
local prompts = vim.tbl_extend('force', default_prompts, options and options.prompts or {})
vim.g.copilot_chat_user_prompts = prompts
-- Loop through merged table and generate commands based on keys.
for key, value in pairs(prompts) do
utils.create_cmd('CopilotChat' .. key, function()
vim.cmd('CopilotChat ' .. value)
end, { nargs = '*', range = true })
end
utils.log_info(
'Execute ":UpdateRemotePlugins" and restart Neovim before starting a chat with Copilot.'
)
utils.log_info('If issues arise, run ":healthcheck" and share the output.')
end
return M