39 lines
1006 B
Lua
39 lines
1006 B
Lua
return {
|
|
{
|
|
"jackMort/ChatGPT.nvim",
|
|
event = "VeryLazy",
|
|
dependencies = {
|
|
"MunifTanjim/nui.nvim",
|
|
"nvim-lua/plenary.nvim",
|
|
"folke/trouble.nvim",
|
|
"nvim-telescope/telescope.nvim"
|
|
},
|
|
config = function()
|
|
local chatgpt = require("chatgpt")
|
|
chatgpt.setup({
|
|
openai_params = {
|
|
model = "gpt-4-1106-preview", -- O usa "gpt-3.5-turbo" si prefieres rapidez
|
|
max_tokens = 4095,
|
|
temperature = 0.2,
|
|
top_p = 0.1,
|
|
n = 1,
|
|
}
|
|
})
|
|
|
|
-- Crear comando `:ChatGPTComplete` para insertar código como snippet
|
|
vim.api.nvim_create_user_command("ChatGPTComplete", function()
|
|
chatgpt.edit_with_instructions({
|
|
callback = function(output)
|
|
local lines = vim.split(output, "\n")
|
|
local snippet = table.concat(lines, "\n")
|
|
vim.fn["vsnip#anonymous"](snippet)
|
|
end
|
|
})
|
|
end, {})
|
|
|
|
-- Atajo de teclado para autocompletar con IA
|
|
vim.keymap.set("n", "<leader>ac", "<cmd>ChatGPTComplete<CR>", { noremap = true, silent = true })
|
|
end,
|
|
}
|
|
}
|