From 94c85d4d33533eb9b92a23beb4e5f3169340c260 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 4 Apr 2024 22:43:13 +0545 Subject: [PATCH] . --- config/nvim/lazyvim.json | 1 + config/nvim/lua/config/keymaps.lua | 1 + .../nvim/lua/plugins/extras/coding/ai/gen.lua | 84 +++++++++++++------ .../plugins/extras/lang/python-extended.lua | 26 +++++- 4 files changed, 86 insertions(+), 26 deletions(-) diff --git a/config/nvim/lazyvim.json b/config/nvim/lazyvim.json index 892366b9..585d4246 100644 --- a/config/nvim/lazyvim.json +++ b/config/nvim/lazyvim.json @@ -3,6 +3,7 @@ "lazyvim.plugins.extras.ui.edgy", "lazyvim.plugins.extras.util.dot", "plugins.extras.coding.ai.codeium", + "plugins.extras.coding.ai.gen", "plugins.extras.coding.annotation", "plugins.extras.coding.multicursor", "plugins.extras.coding.recorder", diff --git a/config/nvim/lua/config/keymaps.lua b/config/nvim/lua/config/keymaps.lua index ed9817e1..1941689a 100644 --- a/config/nvim/lua/config/keymaps.lua +++ b/config/nvim/lua/config/keymaps.lua @@ -40,6 +40,7 @@ end -- Buffers map("n", "bf", "bfirst", { desc = "First Buffer" }) map("n", "ba", "blast", { desc = "Last Buffer" }) +map("n", "b", "tabnew %", { desc = "Current Buffer in New Tab" }) -- Center the screen automatically map("n", "n", "nzzzv") diff --git a/config/nvim/lua/plugins/extras/coding/ai/gen.lua b/config/nvim/lua/plugins/extras/coding/ai/gen.lua index d97d70d9..f620fe56 100644 --- a/config/nvim/lua/plugins/extras/coding/ai/gen.lua +++ b/config/nvim/lua/plugins/extras/coding/ai/gen.lua @@ -1,29 +1,63 @@ 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) + { + "jellydn/gen.nvim", + opts = { + model = "codellama", + host = "localhost", + port = "11434", + 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 = function(options) + local body = { model = options.model, stream = true } + return "curl --silent --no-buffer -X POST http://" + .. options.host + .. ":" + .. options.port + .. "/api/generate -d $body" + end, + }, + 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)" }, + 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 = { + { "ii", "Gen", mode = { "n", "v" }, desc = "IA (Gen)" }, + { "ig", "Gen Generate", mode = { "n" }, desc = "Generate" }, + { "ic", "Gen Chat", mode = { "n" }, desc = "Chat" }, + { "is", "Gen Summarize", mode = { "n", "v" }, desc = "Summarize" }, + { "ia", "Gen Ask", mode = { "v" }, desc = "Ask" }, + { "iH", "Gen Change", mode = { "v" }, desc = "Change" }, + { "iG", "Gen Enhance_Grammar_Spelling", mode = { "v" }, desc = "Enhance Grammar Spelling" }, + { "iw", "Gen Enhance_Wording", mode = { "v" }, desc = "Enhance Wording" }, + { "iC", "Gen Make_Concise", mode = { "v" }, desc = "Make Concise" }, + { "il", "Gen Make_List", mode = { "v" }, desc = "Make List" }, + { "it", "Gen Make_Table", mode = { "v" }, desc = "Make Table" }, + { "ir", "Gen Review_Code", mode = { "v" }, desc = "Review Code" }, + { "ie", "Gen Enhance_Code", mode = { "v" }, desc = "Enhance Code" }, + { "ih", "Gen Change_Code", mode = { "v" }, desc = "Change Code" }, + { "if", "Gen Fix_Code", mode = { "v" }, desc = "Fix Code" }, + { "iE", "Gen Elaborate_Text", mode = { "v" }, desc = "Elaborate Text" }, + }, + }, + { + "folke/which-key.nvim", + opts = { + defaults = { + ["i"] = { name = "󱚦 IA (Gen)" }, + }, + }, }, } diff --git a/config/nvim/lua/plugins/extras/lang/python-extended.lua b/config/nvim/lua/plugins/extras/lang/python-extended.lua index e51ac712..683e69c0 100644 --- a/config/nvim/lua/plugins/extras/lang/python-extended.lua +++ b/config/nvim/lua/plugins/extras/lang/python-extended.lua @@ -1,10 +1,34 @@ +-- LSP Server to use for Python. +-- Set to "basedpyright" to use basedpyright instead of pyright. +vim.g.lazyvim_python_lsp = "basedpyright" + return { { import = "lazyvim.plugins.extras.lang.python" }, - { import = "lazyvim.plugins.extras.lang.python-semshi" }, { "neovim/nvim-lspconfig", opts = { servers = { + ---@type lspconfig.options.basedpyright + basedpyright = { + settings = { + basedpyright = { + analysis = { + diagnosticSeverityOverrides = { + reportUnusedCallResult = "information", + reportUnusedExpression = "information", + reportUnknownMemberType = "none", + reportUnknownLambdaType = "none", + reportUnknownParameterType = "none", + reportMissingParameterType = "none", + reportUnknownVariableType = "none", + reportUnknownArgumentType = "none", + reportAny = "none", + }, + }, + }, + }, + }, + ---@type lspconfig.options.pyright pyright = { settings = { verboseOutput = true,