Fixed up copilot and added copilot chat

This commit is contained in:
Jimmy Bates 2024-06-30 05:04:40 -07:00
parent ea09729865
commit de2044b7e8
5 changed files with 58 additions and 12 deletions

View file

@ -32,6 +32,7 @@ return {
cpp = { 'clang-format' },
yaml = { 'yamlfmt' },
html = { 'djlint' },
htmldjango = { 'djlint' },
css = { { 'prettierd', 'prettier' } },
json = { 'deno_fmt' },
-- Conform can also run multiple formatters sequentially

View file

@ -0,0 +1,28 @@
return {
{
'CopilotC-Nvim/CopilotChat.nvim',
event = 'VeryLazy',
branch = 'canary',
dependencies = {
{ 'zbirenbaum/copilot.lua' }, -- or github/copilot.vim
{ 'nvim-lua/plenary.nvim' }, -- for curl, log wrapper
},
opts = {},
keys = {
{ '<leader>ho', '<cmd>CopilotChat<cr>', mode = { 'n', 'v' }, desc = 'CopilotChat - Open' },
{ '<leader>he', '<cmd>CopilotChatExplain<cr>', mode = { 'n', 'v' }, desc = 'CopilotChat - Explain code' },
{ '<leader>hr', '<cmd>CopilotChatReview<cr>', mode = { 'n', 'v' }, desc = 'CopilotChat - Review code' },
-- { '<leader>hR', '<cmd>CopilotChatRefactor<cr>', mode = { 'n', 'v' }, desc = 'CopilotChat - Refactor code' },
{
'<leader>hf',
'<cmd>CopilotChatFixDiagnostic<cr>', -- Get a fix for the diagnostic message under the cursor.
desc = 'CopilotChat - Fix diagnostic',
},
{
'<leader>hr',
'<cmd>CopilotChatReset<cr>', -- Reset chat history and clear buffer.
desc = 'CopilotChat - Reset chat history and clear buffer',
},
},
},
}

View file

@ -1,13 +1,27 @@
return {
'github/copilot.vim',
'zbirenbaum/copilot.lua',
lazy = false,
init = function()
local map = vim.api.nvim_set_keymap
map('i', '<C-o>', 'copilot#Accept("<CR>")', { expr = true, silent = true })
vim.g.copilot_no_tab_map = true
vim.g.copilot_assume_mapped = true
vim.g.copilot_tab_fallback = ''
end,
cmd = 'Copilot',
event = 'InsertEnter',
opts = {
panel = {
auto_refresh = true,
layout = {
position = 'right',
ratio = 0.3,
},
keymap = {
open = '<C-S-O>',
},
},
suggestion = {
auto_trigger = false,
keymap = {
accept = '<C-o>',
next = '<C-i>',
dismiss = '<C-d>',
prev = '<C-S-i>',
},
},
},
}