From 8ba641b5267474df77c8a5053e810f39ce7f2a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sun, 22 Oct 2023 01:35:38 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20gpt=20extra=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit still have to configure the api key --- .config/nvim/lazyvim.json | 3 +- .config/nvim/lua/plugins/extras/gpt.lua | 102 ++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 .config/nvim/lua/plugins/extras/gpt.lua diff --git a/.config/nvim/lazyvim.json b/.config/nvim/lazyvim.json index 9306601f..d6166dac 100644 --- a/.config/nvim/lazyvim.json +++ b/.config/nvim/lazyvim.json @@ -35,6 +35,7 @@ "plugins.extras.documentation", "plugins.extras.git", "plugins.extras.github", + "plugins.extras.gpt", "plugins.extras.harpoon", "plugins.extras.lsp", "plugins.extras.multicursor", @@ -51,4 +52,4 @@ "NEWS.md": "2123" }, "version": 2 -} +} \ No newline at end of file diff --git a/.config/nvim/lua/plugins/extras/gpt.lua b/.config/nvim/lua/plugins/extras/gpt.lua new file mode 100644 index 00000000..052cf702 --- /dev/null +++ b/.config/nvim/lua/plugins/extras/gpt.lua @@ -0,0 +1,102 @@ +return { + { + "jackMort/ChatGPT.nvim", + opts = { + api_key_cmd = nil, --TODO: manage the API key + edit_with_instructions = { + diff = false, + keymaps = { + close = "", + accept = "", + toggle_diff = "", + toggle_settings = "", + cycle_windows = "", + use_output_as_input = "", + }, + }, + chat = { + welcome_message = "", + keymaps = { + close = { "" }, + yank_last = "", + yank_last_code = "", + scroll_up = "", + scroll_down = "", + new_session = "", + cycle_windows = "", + cycle_modes = "", + next_message = "", + prev_message = "", + select_session = { "", "o", "" }, + rename_session = "r", + delete_session = "d", + draft_message = "", + edit_message = "e", + delete_message = "d", + toggle_settings = "", + toggle_message_role = "", + toggle_system_role_open = "", + stop_generating = "", + }, + }, + openai_params = { + model = "gpt-3.5-turbo-16k", + -- model = "gpt-4", + frequency_penalty = 0, + presence_penalty = 0, + max_tokens = 300, + temperature = 0.3, + top_p = 0.3, + n = 1, + -- temperature = 0, + -- top_p = 1, + }, + openai_edit_params = { + model = "gpt-3.5-turbo-16k", + -- model = "gpt-4", + frequency_penalty = 0, + presence_penalty = 0, + temperature = 0, + top_p = 1, + n = 1, + }, + show_quickfixes_cmd = "Trouble quickfix", + -- actions_paths = { "~/.config/nvim/custom_actions.json" }, + }, + cmd = { + "ChatGPT", + "ChatGPTActAs", + "ChatGPTCompleteCode", + "ChatGPTEditWithInstructions", + "ChatGPTRun", + }, + keys = { + { "Cc", "ChatGPT", desc = "ChatGPT" }, + { "Ce", "ChatGPTEditWithInstruction", desc = "Edit with instruction", mode = { "n", "v" } }, + { "Cg", "ChatGPTRun grammar_correction", desc = "Grammar Correction", mode = { "n", "v" } }, + { "Ct", "ChatGPTRun translate", desc = "Translate", mode = { "n", "v" } }, + { "Ck", "ChatGPTRun keywords", desc = "Keywords", mode = { "n", "v" } }, + { "Cd", "ChatGPTRun docstring", desc = "Docstring", mode = { "n", "v" } }, + { "Ca", "ChatGPTRun add_tests", desc = "Add Tests", mode = { "n", "v" } }, + { "Co", "ChatGPTRun optimize_code", desc = "Optimize Code", mode = { "n", "v" } }, + { "Cs", "ChatGPTRun summarize", desc = "Summarize", mode = { "n", "v" } }, + { "Cf", "ChatGPTRun fix_bugs", desc = "Fix Bugs", mode = { "n", "v" } }, + { "Cx", "ChatGPTRun explain_code", desc = "Explain Code", mode = { "n", "v" } }, + { "Cr", "ChatGPTRun roxygen_edit", desc = "Roxygen Edit", mode = { "n", "v" } }, + { + "Cl", + "ChatGPTRun code_readability_analysis", + desc = "Code Readability Analysis", + mode = { "n", "v" }, + }, + }, + }, + { + "folke/which-key.nvim", + opts = { + defaults = { + ["C"] = { name = "+chatGPT" }, + }, + }, + }, +}