aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins
diff options
context:
space:
mode:
authorElvis Claros Castro <elvis@claros.ar>2025-01-09 10:33:28 -0300
committerElvis Claros Castro <elvis@claros.ar>2025-01-09 10:33:28 -0300
commitf27115f7c053d1d8e4b2af4b7506210fffc51c95 (patch)
tree7eb8b43a6b4f9bb5555eeec9073cf339ccb580b6 /lua/plugins
parent4439edc5a91582f570551e5e849347a80bde40ee (diff)
downloadnvim-conf-f27115f7c053d1d8e4b2af4b7506210fffc51c95.tar.gz
nvim-conf-f27115f7c053d1d8e4b2af4b7506210fffc51c95.zip
Feat: agrego más plugins
Diffstat (limited to 'lua/plugins')
-rw-r--r--lua/plugins/codecompanion.lua146
-rw-r--r--lua/plugins/copilot-chat.lua95
-rw-r--r--lua/plugins/markdown-render.lua5
-rw-r--r--lua/plugins/nvim-dap-python.lua3
4 files changed, 235 insertions, 14 deletions
diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua
index a98a7af..324f4d2 100644
--- a/lua/plugins/codecompanion.lua
+++ b/lua/plugins/codecompanion.lua
@@ -1,15 +1,139 @@
+local IS_DEV = false
return {
- "olimorris/codecompanion.nvim",
- dependencies = {
- "nvim-lua/plenary.nvim",
+ {
"nvim-treesitter/nvim-treesitter",
- "hrsh7th/nvim-cmp", -- Optional: For using slash commands and variables in the chat buffer
- "nvim-telescope/telescope.nvim", -- Optional: For using slash commands
- {
- "MeanderingProgrammer/render-markdown.nvim",
- ft = { "markdown", "codecompanion" },
- }, -- Optional: For prettier markdown rendering
- { "stevearc/dressing.nvim", opts = {} }, -- Optional: Improves `vim.ui.select`
+ opts = { ensure_installed = { "yaml", "markdown" } },
+ },
+ {
+ dir = IS_DEV and "~/Projects/research/codecompanion.nvim" or nil,
+ "olimorris/codecompanion.nvim",
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ "nvim-treesitter/nvim-treesitter",
+ "ibhagwan/fzf-lua", -- For fzf provider, file or buffer picker
+ "jellydn/spinner.nvim", -- Show loading spinner when request is started
+ },
+ opts = {
+ adapters = {
+ ollama = function()
+ return require("codecompanion.adapters").extend("ollama", {
+ name = "tinyllama",
+ env = {
+ url = "http://127.0.0.1:11434",
+ -- api_key = "",
+ },
+ headers = {
+ ["Content-Type"] = "application/json",
+ -- ["Authorization"] = "Bearer ${api_key}",
+ },
+ parameters = {
+ sync = true,
+ },
+ schema = {
+ model = {
+ default = "tinyllama:1.1b",
+ },
+ },
+ })
+ end,
+ anthropic = function()
+ return require("codecompanion.adapters").extend("anthropic", {
+ env = {
+ api_key = "cmd:echo $ANTHROPIC_API_KEY",
+ },
+ schema = {
+ model = {
+ default = "claude-3-opus-20240229",
+ },
+ },
+ })
+ end,
+ copilot = function()
+ return require("codecompanion.adapters").extend("copilot", {
+ schema = {
+ model = {
+ default = "claude-3.5-sonnet",
+ },
+ },
+ })
+ end,
+ gemini = function()
+ return require("codecompanion.adapters").extend("gemini", {
+ env = {
+ api_key = "cmd:op read op://personal/Gemini_API/credential --no-newline",
+ },
+ })
+ end,
+ openai = function()
+ return require("codecompanion.adapters").extend("openai", {
+ env = {
+ api_key = "cmd:echo $OPENAI_API_KEY",
+ chat_url = "/v1/chat/completions",
+ url = "https://api.openai.com",
+ },
+ schema = {
+ model = {
+ default = function()
+ return "gpt-4o-mini"
+ end,
+ },
+ },
+ })
+ end,
+ openai_compatible = function()
+ return require("codecompanion.adapters").extend("openai_compatible", {
+ env = {
+ api_key = "cmd:echo $OPENAI_API_KEY",
+ chat_url = "/v1/chat/completions",
+ url = "http://127.0.0.1:8080",
+ },
+ headers = {
+ ["Content-Type"] = "application/json",
+ },
+ schema = {
+ model = {
+ default = function()
+ return "davinci"
+ end,
+ },
+ },
+ })
+ end,
+ xai = function()
+ return require("codecompanion.adapters").extend("xai", {
+ env = {
+ api_key = "cmd:op read op://personal/xAI_API/credential --no-newline",
+ },
+ })
+ end,
+ },
+ strategies = {
+ chat = {
+ adapter = "copilot",
+ -- roles = { llm = " Copilot Chat", user = "IT Man" },
+ },
+ inline = { adapter = "copilot" },
+ agent = { adapter = "copilot" },
+ },
+ },
+ config = function(_, options)
+ require("codecompanion").setup(options)
+
+ -- Show loading spinner when request is started
+ local spinner = require("spinner")
+ local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})
+ vim.api.nvim_create_autocmd({ "User" }, {
+ pattern = "CodeCompanionRequest*",
+ group = group,
+ callback = function(request)
+ if request.match == "CodeCompanionRequestStarted" then
+ spinner.show()
+ end
+ if request.match == "CodeCompanionRequestFinished" then
+ spinner.hide()
+ end
+ end,
+ })
+ end,
},
- config = true,
}
diff --git a/lua/plugins/copilot-chat.lua b/lua/plugins/copilot-chat.lua
index dc31b32..d389d2f 100644
--- a/lua/plugins/copilot-chat.lua
+++ b/lua/plugins/copilot-chat.lua
@@ -1,8 +1,35 @@
+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 {
{
+ "nvim-treesitter/nvim-treesitter",
+ opts = { ensure_installed = { "diff", "markdown" } },
+ },
+ {
+ dir = IS_DEV and "~/research/CopilotChat.nvim" or nil,
"CopilotC-Nvim/CopilotChat.nvim",
+ -- version = "v3.3.0",
dependencies = {
- { "nvim-lua/plenary.nvim", branch = "master" }, -- for curl, log and async functions
+ { "nvim-lua/plenary.nvim" },
{
"ibhagwan/fzf-lua",
config = function()
@@ -11,8 +38,70 @@ return {
},
},
opts = {
- -- See Configuration section for options
+ model = 'claude-3.5-sonnet',
+ -- question_header = "## User ",
+ -- answer_header = "## Copilot ",
+ -- error_header = "## Error ",
+ prompts = prompts,
+ -- Turn off Claude model as it's not working well
+ -- model = "claude-3.5-sonnet",
+ auto_follow_cursor = false, -- Don't follow the cursor after getting response
+
},
- -- See Commands section for default commands if you want to lazy load on them
+ config = function(_, opts)
+ local chat = require("CopilotChat")
+ local select = require("CopilotChat.select")
+ -- Use unnamed register for the selection
+ opts.selection = select.unnamed
+
+ -- local hostname = io.popen("hostname"):read("*a"):gsub("%s+", "")
+ -- local user = hostname or vim.env.USER or "User"
+ -- opts.question_header = " " .. user .. " "
+ -- opts.answer_header = " Copilot "
+ -- Override the git prompts message
+ opts.prompts.Commit = {
+ prompt = '> #git:staged\n\nWrite commit message with commitizen convention. Write clear, informative commit messages that explain the "what" and "why" behind changes, not just the "how".',
+ }
+
+ 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,
},
}
diff --git a/lua/plugins/markdown-render.lua b/lua/plugins/markdown-render.lua
new file mode 100644
index 0000000..6263fd9
--- /dev/null
+++ b/lua/plugins/markdown-render.lua
@@ -0,0 +1,5 @@
+return {
+ "MeanderingProgrammer/render-markdown.nvim",
+ ft = { "markdown", "codecompanion", "copilot-chat" },
+}
+
diff --git a/lua/plugins/nvim-dap-python.lua b/lua/plugins/nvim-dap-python.lua
new file mode 100644
index 0000000..da973e4
--- /dev/null
+++ b/lua/plugins/nvim-dap-python.lua
@@ -0,0 +1,3 @@
+return {
+ "mfussenegger/nvim-dap-python",
+}