From 6dfeeb0d01f54ca7516545bd6f87a6cf9b28967b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Mon, 15 Jan 2024 11:40:08 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20add=20gen.nvim=20extr?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/.github/README.md | 1 + .../nvim/lua/plugins/extras/coding/ai/gen.lua | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .config/nvim/lua/plugins/extras/coding/ai/gen.lua diff --git a/.config/nvim/.github/README.md b/.config/nvim/.github/README.md index c7e07733..10b0374e 100644 --- a/.config/nvim/.github/README.md +++ b/.config/nvim/.github/README.md @@ -46,6 +46,7 @@ - [tzachar/cmp-tabnine](https://github.com/tzachar/cmp-tabnine) - [jackMort/ChatGPT.nvim](https://dotfyle.com/plugins/jackMort/ChatGPT.nvim) - [zbirenbaum/copilot.lua](https://dotfyle.com/plugins/zbirenbaum/copilot.lua) +- [David-Kunz/gen.nvim](https://dotfyle.com/plugins/David-Kunz/gen.nvim) diff --git a/.config/nvim/lua/plugins/extras/coding/ai/gen.lua b/.config/nvim/lua/plugins/extras/coding/ai/gen.lua new file mode 100644 index 00000000..d97d70d9 --- /dev/null +++ b/.config/nvim/lua/plugins/extras/coding/ai/gen.lua @@ -0,0 +1,29 @@ +return { + "jellydn/gen.nvim", + opts = { + model = "codellama", + display_mode = "split", + show_prompt = true, + show_model = true, + no_auto_close = false, + init = function(options) + pcall(io.popen, "ollama serve > /dev/null 2>&1 &") + end, + command = "curl --silent --no-buffer -X POST http://localhost:11434/api/generate -d $body", + }, + config = function(_, opts) + local gen = require("gen") + gen.setup(opts) + + gen.prompts["Elaborate_Text"] = { + prompt = "Elaborate the following text:\n$text", + } + gen.prompts["Fix_Code"] = { + prompt = "Fix the following code. Only output the result in format ```$filetype\n...\n```:\n```$filetype\n$text\n```", + extract = "```$filetype\n(.-)```", + } + end, + keys = { + { "i", "Gen", mode = { "n", "v" }, desc = "IA (Gen)" }, + }, +}