aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins
diff options
context:
space:
mode:
authorElvis Claros Castro <elvis@claros.ar>2024-12-09 11:24:40 -0300
committerElvis Claros Castro <elvis@claros.ar>2024-12-09 11:24:40 -0300
commit4439edc5a91582f570551e5e849347a80bde40ee (patch)
tree00e93e727e43b5e98fbd38dbb6be5b60f2203847 /lua/plugins
parente00fc002a6441fa3741d1f705337efbbd8850744 (diff)
downloadnvim-conf-4439edc5a91582f570551e5e849347a80bde40ee.tar.gz
nvim-conf-4439edc5a91582f570551e5e849347a80bde40ee.zip
Modifico Las configuraciones de copilot-chat
Diffstat (limited to 'lua/plugins')
-rw-r--r--lua/plugins/copilot-chat.lua224
1 files changed, 9 insertions, 215 deletions
diff --git a/lua/plugins/copilot-chat.lua b/lua/plugins/copilot-chat.lua
index 0ae500d..dc31b32 100644
--- a/lua/plugins/copilot-chat.lua
+++ b/lua/plugins/copilot-chat.lua
@@ -1,224 +1,18 @@
-local IS_DEV = false
-
-local prompts = {
- -- Code related 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.",
- Refactor = "Please refactor the following code to improve its clarity and readability.",
- FixCode = "Please fix the following code to make it work as intended.",
- FixError = "Please explain the error in the following text and provide a solution.",
- BetterNamings = "Please provide better names for the following variables and functions.",
- Documentation = "Please provide documentation for the following code.",
- SwaggerApiDocs = "Please provide documentation for the following API using Swagger.",
- SwaggerJsDocs = "Please write JSDoc for the following API using Swagger.",
- -- Text related prompts
- Summarize = "Please summarize the following text.",
- Spelling = "Please correct any grammar and spelling errors in the following text.",
- Wording = "Please improve the grammar and wording of the following text.",
- Concise = "Please rewrite the following text to make it more concise.",
-}
-
return {
- -- { import = "plugins.extras.copilot-vim" }, -- Or use { import = "lazyvim.plugins.extras.coding.copilot" },
- {
- "folke/which-key.nvim",
- optional = true,
- opts = {
- spec = {
- { "<leader>a", group = "ai" },
- { "gm", group = "+Copilot chat" },
- { "gmh", desc = "Show help" },
- { "gmd", desc = "Show diff" },
- { "gmp", desc = "Show system prompt" },
- { "gms", desc = "Show selection" },
- { "gmy", desc = "Yank diff" },
- },
- },
- },
{
- dir = IS_DEV and "~/Projects/research/CopilotChat.nvim" or nil,
"CopilotC-Nvim/CopilotChat.nvim",
- -- version = "v3.3.0", -- Use a specific version to prevent breaking changes
dependencies = {
- { "nvim-telescope/telescope.nvim" }, -- Use telescope for help actions
- { "nvim-lua/plenary.nvim" },
- { "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
- },
- opts = {
- question_header = "## User ",
- answer_header = "## Copilot ",
- error_header = "## Error ",
- prompts = prompts,
- auto_follow_cursor = false, -- Don't follow the cursor after getting response
- mappings = {
- -- Use tab for completion
- complete = {
- detail = "Use @<Tab> or /<Tab> for options.",
- insert = "<Tab>",
- },
- -- Close the chat
- close = {
- normal = "q",
- insert = "<C-c>",
- },
- -- Reset the chat buffer
- reset = {
- normal = "<C-x>",
- insert = "<C-x>",
- },
- -- Submit the prompt to Copilot
- submit_prompt = {
- normal = "<CR>",
- insert = "<C-CR>",
- },
- -- Accept the diff
- accept_diff = {
- normal = "<C-y>",
- insert = "<C-y>",
- },
- -- Yank the diff in the response to register
- yank_diff = {
- normal = "gmy",
- },
- -- Show the diff
- show_diff = {
- normal = "gmd",
- },
- -- Show the info
- show_info = {
- normal = "gmi",
- },
- -- Show the context
- show_context = {
- normal = "gmc",
- },
- -- Show help
- show_help = {
- normal = "gmh",
- },
- },
- },
- config = function(_, opts)
- local chat = require("CopilotChat")
- local select = require("CopilotChat.select")
- -- Use unnamed register for the selection
- opts.selection = select.unnamed
-
- chat.setup(opts)
-
- vim.api.nvim_create_user_command("CopilotChatVisual", function(args)
- chat.ask(args.args, { selection = select.visual })
- end, { nargs = "*", range = true })
-
- -- Inline chat with Copilot
- vim.api.nvim_create_user_command("CopilotChatInline", function(args)
- chat.ask(args.args, {
- selection = select.visual,
- window = {
- layout = "float",
- relative = "cursor",
- width = 1,
- height = 0.4,
- row = 1,
- },
- })
- end, { nargs = "*", range = true })
-
- -- Restore CopilotChatBuffer
- vim.api.nvim_create_user_command("CopilotChatBuffer", function(args)
- chat.ask(args.args, { selection = select.buffer })
- end, { nargs = "*", range = true })
-
- -- Custom buffer for CopilotChat
- vim.api.nvim_create_autocmd("BufEnter", {
- pattern = "copilot-*",
- callback = function()
- vim.opt_local.relativenumber = true
- vim.opt_local.number = true
-
- -- Get current filetype and set it to markdown if the current filetype is copilot-chat
- local ft = vim.bo.filetype
- if ft == "copilot-chat" then
- vim.bo.filetype = "markdown"
- end
- end,
- })
- end,
- event = "VeryLazy",
- keys = {
- -- Show prompts actions with telescope
- {
- "<leader>ap",
- function()
- local actions = require("CopilotChat.actions")
- require("CopilotChat.integrations.telescope").pick(actions.prompt_actions())
- end,
- desc = "CopilotChat - Prompt actions",
- },
+ { "nvim-lua/plenary.nvim", branch = "master" }, -- for curl, log and async functions
{
- "<leader>ap",
- ":lua require('CopilotChat.integrations.telescope').pick(require('CopilotChat.actions').prompt_actions({selection = require('CopilotChat.select').visual}))<CR>",
- mode = "x",
- desc = "CopilotChat - Prompt actions",
+ "ibhagwan/fzf-lua",
+ config = function()
+ require("fzf-lua").setup({})
+ end
},
- -- Code related commands
- { "<leader>ae", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
- { "<leader>at", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
- { "<leader>ar", "<cmd>CopilotChatReview<cr>", desc = "CopilotChat - Review code" },
- { "<leader>aR", "<cmd>CopilotChatRefactor<cr>", desc = "CopilotChat - Refactor code" },
- { "<leader>an", "<cmd>CopilotChatBetterNamings<cr>", desc = "CopilotChat - Better Naming" },
- -- Chat with Copilot in visual mode
- {
- "<leader>av",
- ":CopilotChatVisual",
- mode = "x",
- desc = "CopilotChat - Open in vertical split",
- },
- {
- "<leader>ax",
- ":CopilotChatInline<cr>",
- mode = "x",
- desc = "CopilotChat - Inline chat",
- },
- -- Custom input for CopilotChat
- {
- "<leader>ai",
- function()
- local input = vim.fn.input("Ask Copilot: ")
- if input ~= "" then
- vim.cmd("CopilotChat " .. input)
- end
- end,
- desc = "CopilotChat - Ask input",
- },
- -- Generate commit message based on the git diff
- {
- "<leader>am",
- "<cmd>CopilotChatCommit<cr>",
- desc = "CopilotChat - Generate commit message for all changes",
- },
- -- Quick chat with Copilot
- {
- "<leader>aq",
- function()
- local input = vim.fn.input("Quick Chat: ")
- if input ~= "" then
- vim.cmd("CopilotChatBuffer " .. input)
- end
- end,
- desc = "CopilotChat - Quick chat",
- },
- -- Debug
- { "<leader>ad", "<cmd>CopilotChatDebugInfo<cr>", desc = "CopilotChat - Debug Info" },
- -- Fix the issue with diagnostic
- { "<leader>af", "<cmd>CopilotChatFixDiagnostic<cr>", desc = "CopilotChat - Fix Diagnostic" },
- -- Clear buffer and chat history
- { "<leader>al", "<cmd>CopilotChatReset<cr>", desc = "CopilotChat - Clear buffer and chat history" },
- -- Toggle Copilot Chat Vsplit
- { "<leader>av", "<cmd>CopilotChatToggle<cr>", desc = "CopilotChat - Toggle" },
- -- Copilot Chat Models
- { "<leader>a?", "<cmd>CopilotChatModels<cr>", desc = "CopilotChat - Select Models" },
},
+ opts = {
+ -- See Configuration section for options
+ },
+ -- See Commands section for default commands if you want to lazy load on them
},
}