fix: changes for file paths

This commit is contained in:
2024-12-12 20:25:26 +01:00
parent 78b0172772
commit 30b119e5f9
5 changed files with 24 additions and 63 deletions

View File

@@ -1,14 +1,3 @@
-- lua/chatgpt_nvim/init.lua
-- Modified to:
-- 1) Use YAML for config and response parsing.
-- 2) Assume ChatGPT response is YAML of form:
-- files:
-- - path: "somefile.lua"
-- content: |
-- multi line
-- content
--
local M = {}
local context = require('chatgpt_nvim.context')
@@ -21,10 +10,9 @@ local function copy_to_clipboard(text)
vim.fn.setreg('+', text)
end
-- Parse the response from ChatGPT in YAML.
local function parse_response(raw)
if not ok_yaml then
vim.api.nvim_err_writeln("lyaml is not available. Please install lyaml for YAML parsing.")
vim.api.nvim_err_writeln("lyaml not available. Install with `luarocks install lyaml`.")
return nil
end
local ok, data = pcall(lyaml.load, raw)
@@ -32,7 +20,6 @@ local function parse_response(raw)
vim.api.nvim_err_writeln("Failed to parse YAML response.")
return nil
end
-- lyaml.load returns a list of documents. We assume only one document is given.
data = data[1]
return data
end
@@ -53,21 +40,17 @@ function M.run_chatgpt_command()
local readme_content = context.get_readme_content()
local sections = {
conf.initial_prompt .. "\n",
user_input,
"\n\nproject structure:\n",
conf.initial_prompt .. "\n" .. user_input,
"\n\nProject Structure:\n",
project_structure,
"\n\nproject files:\n"
"\n\nFiels:\n",
}
-- Add all other files in configured directories
table.insert(sections, file_sections)
local prompt = table.concat(sections, "\n")
-- Copy prompt to clipboard
copy_to_clipboard(prompt)
print("Prompt copied to clipboard! Please paste it into the ChatGPT O1 model and get the YAML response.")
print("Prompt copied to clipboard! Paste it into the ChatGPT O1 model.")
end
function M.run_chatgpt_paste_command()