From 28cffd0480e3c91460c295a12e1bb0e650def8b2 Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:30:47 -0500 Subject: [PATCH] Update init.lua --- lua/Javanvim/init.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lua/Javanvim/init.lua b/lua/Javanvim/init.lua index 487d24e..9283f2a 100644 --- a/lua/Javanvim/init.lua +++ b/lua/Javanvim/init.lua @@ -18,21 +18,27 @@ end -- Create a new Java project function M.create_project() - local project_name = vim.fn.input("Enter project name: ") + -- Ensure the prompt is a string (to avoid invalid arguments) + local prompt = "Enter project name: " - -- Debug: Print the project_name + -- Use vim.fn.input to capture the input + local project_name = vim.fn.input(prompt) + + -- Debugging: Output the input received print("Input received: " .. (project_name or "nil")) + -- Check if the project name is valid if not project_name or project_name == "" then print("Project creation canceled.") return end + -- Paths for the project local project_root = vim.fn.expand(M.config.project_root) .. "/" .. project_name local src_dir = project_root .. "/root/src" local out_dir = project_root .. "/root/out" - -- Debug: Print paths + -- Debugging: Print the paths print("Project root: " .. project_root) print("Source directory: " .. src_dir) print("Output directory: " .. out_dir) @@ -41,7 +47,7 @@ function M.create_project() vim.fn.mkdir(src_dir, "p") vim.fn.mkdir(out_dir, "p") - -- Write Main.java + -- Write the Main.java file local main_java_path = src_dir .. "/Main.java" local main_java_content = [[ public class Main { @@ -50,6 +56,8 @@ public class Main { } } ]] + + -- Create the file and write content local file = io.open(main_java_path, "w") if file then file:write(main_java_content)