diff --git a/lua/chatgpt_nvim/init.lua b/lua/chatgpt_nvim/init.lua index 0b10f51..f209443 100644 --- a/lua/chatgpt_nvim/init.lua +++ b/lua/chatgpt_nvim/init.lua @@ -173,8 +173,8 @@ local function build_prompt(user_input, dirs, conf) table.insert(final_sections, table.concat(env_lines, "\n")) local final_prompt = table.concat(final_sections, "\n\n") - -- Replace placeholder "chatgpt.vim" with the actual project name from configuration - final_prompt = final_prompt:gsub("%chatgpt.vim%", conf.project_name) + -- Replace placeholder "%PROJECT_NAME%" with the actual project name from configuration + final_prompt = final_prompt:gsub("%%PROJECT_NAME%%", conf.project_name) return final_prompt end @@ -453,8 +453,13 @@ local function run_chatgpt_current_buffer_command() end ------------------------------------------------------------------------------ --- GLOBAL FILE COMPLETION FUNCTION +-- PUBLIC API ------------------------------------------------------------------------------ +M.run_chatgpt_command = run_chatgpt_command +M.run_chatgpt_paste_command = run_chatgpt_paste_command +M.run_chatgpt_current_buffer_command = run_chatgpt_current_buffer_command + +-- New: Global function for file name auto-completion in ChatGPT prompt function _G.chatgpt_file_complete(findstart, base) if findstart == 1 then local line = vim.fn.getline('.') @@ -469,8 +474,9 @@ function _G.chatgpt_file_complete(findstart, base) local conf = config.load() local files = context.get_project_files({'.'}, conf) local completions = {} + local esc_base = base:gsub("([^%w])", "%%%1") for _, f in ipairs(files) do - if f:find(base, 1, true) then + if f:match("^" .. esc_base) then table.insert(completions, f) end end