-
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d479d5
commit 6c614e8
Showing
6 changed files
with
1,102 additions
and
105 deletions.
There are no files selected for viewing
184 changes: 184 additions & 0 deletions
184
tests/test-sources/plugins/by-name/copilot-chat/default-settings/contexts.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
# https://github.com/CopilotC-Nvim/CopilotChat.nvim/blob/main/lua/CopilotChat/config/contexts.lua | ||
{ | ||
buffer = { | ||
description = "Includes specified buffer in chat context. Supports input (default current)."; | ||
input.__raw = '' | ||
function(callback) | ||
vim.ui.select( | ||
vim.tbl_map( | ||
function(buf) | ||
return { id = buf, name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(buf), ':p:.') } | ||
end, | ||
vim.tbl_filter(function(buf) | ||
return utils.buf_valid(buf) and vim.fn.buflisted(buf) == 1 | ||
end, vim.api.nvim_list_bufs()) | ||
), | ||
{ | ||
prompt = 'Select a buffer> ', | ||
format_item = function(item) | ||
return item.name | ||
end, | ||
}, | ||
function(choice) | ||
callback(choice and choice.id) | ||
end | ||
) | ||
end | ||
''; | ||
resolve.__raw = '' | ||
function(input, source) | ||
input = input and tonumber(input) or source.bufnr | ||
return { | ||
context.buffer(input), | ||
} | ||
end | ||
''; | ||
}; | ||
buffers = { | ||
description = "Includes all buffers in chat context. Supports input (default listed)."; | ||
input.__raw = '' | ||
function(callback) | ||
vim.ui.select({ 'listed', 'visible' }, { | ||
prompt = 'Select buffer scope> ', | ||
}, callback) | ||
end | ||
''; | ||
resolve.__raw = '' | ||
function(input) | ||
input = input or 'listed' | ||
return context.buffers(input) | ||
end | ||
''; | ||
}; | ||
file = { | ||
description = "Includes content of provided file in chat context. Supports input."; | ||
input.__raw = '' | ||
function(callback, source) | ||
local cwd = utils.win_cwd(source.winnr) | ||
local files = utils.scan_dir(cwd, { | ||
add_dirs = false, | ||
respect_gitignore = true, | ||
max_files = 1000, | ||
}) | ||
async.util.scheduler() | ||
vim.ui.select(files, { | ||
prompt = 'Select a file> ', | ||
}, callback) | ||
end | ||
''; | ||
resolve.__raw = '' | ||
function(input) | ||
return { | ||
context.file(input), | ||
} | ||
end | ||
''; | ||
}; | ||
files = { | ||
description = "Includes all non-hidden files in the current workspace in chat context. Supports input (default list)."; | ||
input.__raw = '' | ||
function(callback) | ||
local choices = utils.kv_list({ | ||
list = 'Only lists file names', | ||
full = 'Includes file content for each file found, up to a limit.', | ||
}) | ||
vim.ui.select(choices, { | ||
prompt = 'Select files content> ', | ||
format_item = function(choice) | ||
return choice.key .. ' - ' .. choice.value | ||
end, | ||
}, function(choice) | ||
callback(choice and choice.key) | ||
end) | ||
end | ||
''; | ||
resolve.__raw = '' | ||
function(input, source) | ||
return context.files(source.winnr, input == 'full') | ||
end | ||
''; | ||
}; | ||
git = { | ||
description = "Requires `git`. Includes current git diff in chat context. Supports input (default unstaged, also accepts commit number)."; | ||
input.__raw = '' | ||
function(callback) | ||
vim.ui.select({ 'unstaged', 'staged' }, { | ||
prompt = 'Select diff type> ', | ||
}, callback) | ||
end | ||
''; | ||
resolve.__raw = '' | ||
function(input, source) | ||
input = input or 'unstaged' | ||
return { | ||
context.gitdiff(input, source.winnr), | ||
} | ||
end | ||
''; | ||
}; | ||
url = { | ||
description = "Includes content of provided URL in chat context. Supports input."; | ||
input.__raw = '' | ||
function(callback) | ||
vim.ui.input({ | ||
prompt = 'Enter URL> ', | ||
default = 'https://', | ||
}, callback) | ||
end | ||
''; | ||
resolve.__raw = '' | ||
function(input) | ||
return { | ||
context.url(input), | ||
} | ||
end | ||
''; | ||
}; | ||
register = { | ||
description = "Includes contents of register in chat context. Supports input (default +, e.g clipboard)."; | ||
input.__raw = '' | ||
function(callback) | ||
local choices = utils.kv_list({ | ||
['+'] = 'synchronized with the system clipboard', | ||
['*'] = 'synchronized with the selection clipboard', | ||
['"'] = 'last deleted, changed, or yanked content', | ||
['0'] = 'last yank', | ||
['-'] = 'deleted or changed content smaller than one line', | ||
['.'] = 'last inserted text', | ||
['%'] = 'name of the current file', | ||
[':'] = 'most recent executed command', | ||
['#'] = 'alternate buffer', | ||
['='] = 'result of an expression', | ||
['/'] = 'last search pattern', | ||
}) | ||
vim.ui.select(choices, { | ||
prompt = 'Select a register> ', | ||
format_item = function(choice) | ||
return choice.key .. ' - ' .. choice.value | ||
end, | ||
}, function(choice) | ||
callback(choice and choice.key) | ||
end) | ||
end | ||
''; | ||
resolve.__raw = '' | ||
function(input) | ||
input = input or '+' | ||
return { | ||
context.register(input), | ||
} | ||
end | ||
''; | ||
}; | ||
quickfix = { | ||
description = "Includes quickfix list file contents in chat context."; | ||
resolve.__raw = '' | ||
function() | ||
return context.quickfix() | ||
end | ||
''; | ||
}; | ||
} |
126 changes: 126 additions & 0 deletions
126
tests/test-sources/plugins/by-name/copilot-chat/default-settings/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# https://github.com/CopilotC-Nvim/CopilotChat.nvim/blob/main/lua/CopilotChat/config.lua | ||
{ | ||
system_prompt = "require('CopilotChat.config.prompts').COPILOT_INSTRUCTIONS"; | ||
model = "gpt-4-o"; | ||
agent = "none"; | ||
context = null; | ||
sticky = null; | ||
|
||
temperature = 0.1; | ||
headless = false; | ||
callback = null; | ||
|
||
selection.__raw = '' | ||
function(source) | ||
local select = require('CopilotChat.select') | ||
return select.visual(source) or select.buffer(source) | ||
end | ||
''; | ||
|
||
window = { | ||
layout = "vertical"; | ||
width = 0.5; | ||
height = 0.5; | ||
relative = "editor"; | ||
border = "single"; | ||
row = null; | ||
col = null; | ||
title = "Copilot Chat"; | ||
footer = null; | ||
zindex = 1; | ||
}; | ||
|
||
show_help = true; | ||
show_folds = true; | ||
highlight_selection = true; | ||
highlight_headers = true; | ||
auto_follow_cursor = true; | ||
auto_insert_mode = false; | ||
insert_at_end = false; | ||
|
||
debug = false; | ||
log_level = "info"; | ||
proxy = null; | ||
allow_insecure = false; | ||
|
||
chat_autocomplete = true; | ||
|
||
log_path.__raw = "vim.fn.stdpath('state') .. '/CopilotChat.log'"; | ||
history_path.__raw = "vim.fn.stdpath('data') .. '/copilotchat_history'"; | ||
|
||
question_header = "## User "; | ||
answer_header = "## Copilot "; | ||
error_header = "## Error "; | ||
separator = "───"; | ||
|
||
providers = import ./providers.nix; | ||
contexts = import ./contexts.nix; | ||
prompts = { }; # TODO | ||
mappings = import ./mappings.nix; | ||
|
||
__prompts = { | ||
Explain.prompt = "/COPILOT_EXPLAIN Write an explanation for the active selection as paragraphs of text."; | ||
Review = { | ||
prompt = "/COPILOT_REVIEW Review the selected code."; | ||
callback = '' | ||
function(response, source) | ||
-- see config.lua for implementation | ||
end | ||
''; | ||
}; | ||
Fix.prompt = "/COPILOT_GENERATE There is a problem in this code. Rewrite the code to show it with the bug fixed."; | ||
Optimize.prompt = "/COPILOT_GENERATE Optimize the selected code to improve performance and readablilty."; | ||
Docs.prompt = "/COPILOT_GENERATE Please add documentation comment for the selection."; | ||
Tests.prompt = "/COPILOT_GENERATE Please generate tests for my code."; | ||
FixDiagnostic = { | ||
prompt = "Please assist with the following diagnostic issue in file:"; | ||
selection = "require('CopilotChat.select').diagnostics"; | ||
}; | ||
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 | ||
''; | ||
}; | ||
}; | ||
|
||
__mappings = { | ||
complete.insert = "<Tab>"; | ||
close = { | ||
normal = "q"; | ||
insert = "<C-c>"; | ||
}; | ||
reset = { | ||
normal = "<C-l>"; | ||
insert = "<C-l>"; | ||
}; | ||
submit_prompt = { | ||
normal = "<CR>"; | ||
insert = "<C-s>"; | ||
}; | ||
toggle_sticky = { | ||
detail = "Makes line under cursor sticky or deletes sticky line."; | ||
normal = "gr"; | ||
}; | ||
accept_diff = { | ||
normal = "<C-y>"; | ||
insert = "<C-y>"; | ||
}; | ||
jump_to_diff.normal = "gj"; | ||
quickfix_diffs.normal = "gq"; | ||
yank_diff = { | ||
normal = "gy"; | ||
register = "\""; | ||
}; | ||
show_diff.normal = "gd"; | ||
show_info.normal = "gi"; | ||
show_context.normal = "gc"; | ||
show_help.normal = "gh"; | ||
}; | ||
} |
Oops, something went wrong.