feat(nvim): gpt extra added

still have to configure the api key
This commit is contained in:
Sergio Laín 2023-10-22 01:35:38 +02:00
parent 33ef723bca
commit 8ba641b526
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
2 changed files with 104 additions and 1 deletions

View file

@ -35,6 +35,7 @@
"plugins.extras.documentation", "plugins.extras.documentation",
"plugins.extras.git", "plugins.extras.git",
"plugins.extras.github", "plugins.extras.github",
"plugins.extras.gpt",
"plugins.extras.harpoon", "plugins.extras.harpoon",
"plugins.extras.lsp", "plugins.extras.lsp",
"plugins.extras.multicursor", "plugins.extras.multicursor",
@ -51,4 +52,4 @@
"NEWS.md": "2123" "NEWS.md": "2123"
}, },
"version": 2 "version": 2
} }

View file

@ -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 = "<C-c>",
accept = "<C-y>",
toggle_diff = "<C-d>",
toggle_settings = "<C-o>",
cycle_windows = "<Tab>",
use_output_as_input = "<C-i>",
},
},
chat = {
welcome_message = "",
keymaps = {
close = { "<C-c>" },
yank_last = "<C-y>",
yank_last_code = "<C-k>",
scroll_up = "<C-u>",
scroll_down = "<C-d>",
new_session = "<C-n>",
cycle_windows = "<Tab>",
cycle_modes = "<C-f>",
next_message = "<C-j>",
prev_message = "<C-k>",
select_session = { "<Space>", "o", "<cr>" },
rename_session = "r",
delete_session = "d",
draft_message = "<C-d>",
edit_message = "e",
delete_message = "d",
toggle_settings = "<C-o>",
toggle_message_role = "<C-r>",
toggle_system_role_open = "<C-s>",
stop_generating = "<C-x>",
},
},
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 = {
{ "<leader>Cc", "<cmd>ChatGPT<CR>", desc = "ChatGPT" },
{ "<leader>Ce", "<cmd>ChatGPTEditWithInstruction<CR>", desc = "Edit with instruction", mode = { "n", "v" } },
{ "<leader>Cg", "<cmd>ChatGPTRun grammar_correction<CR>", desc = "Grammar Correction", mode = { "n", "v" } },
{ "<leader>Ct", "<cmd>ChatGPTRun translate<CR>", desc = "Translate", mode = { "n", "v" } },
{ "<leader>Ck", "<cmd>ChatGPTRun keywords<CR>", desc = "Keywords", mode = { "n", "v" } },
{ "<leader>Cd", "<cmd>ChatGPTRun docstring<CR>", desc = "Docstring", mode = { "n", "v" } },
{ "<leader>Ca", "<cmd>ChatGPTRun add_tests<CR>", desc = "Add Tests", mode = { "n", "v" } },
{ "<leader>Co", "<cmd>ChatGPTRun optimize_code<CR>", desc = "Optimize Code", mode = { "n", "v" } },
{ "<leader>Cs", "<cmd>ChatGPTRun summarize<CR>", desc = "Summarize", mode = { "n", "v" } },
{ "<leader>Cf", "<cmd>ChatGPTRun fix_bugs<CR>", desc = "Fix Bugs", mode = { "n", "v" } },
{ "<leader>Cx", "<cmd>ChatGPTRun explain_code<CR>", desc = "Explain Code", mode = { "n", "v" } },
{ "<leader>Cr", "<cmd>ChatGPTRun roxygen_edit<CR>", desc = "Roxygen Edit", mode = { "n", "v" } },
{
"<leader>Cl",
"<cmd>ChatGPTRun code_readability_analysis<CR>",
desc = "Code Readability Analysis",
mode = { "n", "v" },
},
},
},
{
"folke/which-key.nvim",
opts = {
defaults = {
["<leader>C"] = { name = "+chatGPT" },
},
},
},
}