initial commit

This commit is contained in:
2024-12-10 22:59:20 +01:00
commit 01a482d91f
4 changed files with 160 additions and 0 deletions

39
lua/chatgpt_nvim/init.lua Normal file
View File

@@ -0,0 +1,39 @@
local M = {}
local context = require('chatgpt_nvim.context')
function M.run_chatgpt_command()
vim.schedule(function()
-- Prompt the user for input
local user_input = vim.fn.input("Message for O1 Model: ")
if user_input == "" then
print("No input provided.")
return
end
local project_structure = context.get_project_structure()
local current_file_content, current_file_path = context.get_current_file()
local readme_content = context.get_readme_content()
local sections = {
"User Message:\n" .. user_input,
"\nProject Structure:\n" .. project_structure,
"\nCurrent File:\nPath: " .. current_file_path .. "\n" .. current_file_content,
"\nInstructions:\nPlease return code blocks for the changes. Each code block must start with the file path on the first line, followed by the code.",
"Do not comment out the file path. Just plain text.",
"If multiple files are needed, return multiple code blocks each starting with a file path."
}
if readme_content then
table.insert(sections, "\nREADME Content:\n" .. readme_content)
end
local prompt = table.concat(sections, "\n")
-- Copy prompt to clipboard so user can paste it into the website form.
vim.fn.setreg('+', prompt)
print("Prompt (including README if found) copied to clipboard! Paste it into the website form.")
end)
end
return M