From feab61ce006a3a79d173855a1a9e02a30bece4ae Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:41:08 -0500 Subject: [PATCH 1/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9a3dec..f8ba2f2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ For Lazy.nvim: require { "DarthMooMancer/Javanvim", config = function() - require("Javavim").setup() + require("Javanvim").setup() end } ``` From ef646785a8e06ef31dcfecdb52fabc9fbc69a2d5 Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:14:41 -0500 Subject: [PATCH 2/7] Update init.lua --- lua/Javanvim/init.lua | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/lua/Javanvim/init.lua b/lua/Javanvim/init.lua index e6eeb70..e2ba7b6 100644 --- a/lua/Javanvim/init.lua +++ b/lua/Javanvim/init.lua @@ -24,15 +24,25 @@ function M.create_project() return end + -- Expand and sanitize the project root path 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" - -- Create directories - vim.fn.mkdir(src_dir, "p") - vim.fn.mkdir(out_dir, "p") + -- Debugging: Print paths + print("Creating project at:", project_root) - -- Write Main.java + -- Create directories + local mkdir_status1 = vim.fn.mkdir(src_dir, "p") + local mkdir_status2 = vim.fn.mkdir(out_dir, "p") + + -- Debugging: Check if directories were created + if not vim.loop.fs_stat(src_dir) or not vim.loop.fs_stat(out_dir) then + print("Error: Failed to create project directories.") + return + end + + -- Path for Main.java local main_java_path = src_dir .. "/Main.java" local main_java_content = [[ public class Main { @@ -41,15 +51,19 @@ public class Main { } } ]] - local file = io.open(main_java_path, "w") - if file then - file:write(main_java_content) - file:close() - vim.cmd("edit " .. main_java_path) - print("Project '" .. project_name .. "' created at " .. project_root) - else - print("Error creating Main.java") + + -- Attempt to write to the file + local file, err = io.open(main_java_path, "w") + if not file then + print("Error creating Main.java:", err) + return end + file:write(main_java_content) + file:close() + + -- Open the new Java file + vim.cmd("edit " .. main_java_path) + print("Project '" .. project_name .. "' created at " .. project_root) end) end From a7f371bec6acb723478a4baccb8e7b7888a31e26 Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:26:23 -0500 Subject: [PATCH 3/7] Update init.lua --- lua/Javanvim/init.lua | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/lua/Javanvim/init.lua b/lua/Javanvim/init.lua index e2ba7b6..dacdccd 100644 --- a/lua/Javanvim/init.lua +++ b/lua/Javanvim/init.lua @@ -19,30 +19,28 @@ end -- Create a new Java project function M.create_project() vim.ui.input({ prompt = "Enter project name: " }, function(project_name) + -- Debug: Print the project_name + print("Input received: " .. (project_name or "nil")) + if not project_name or project_name == "" then print("Project creation canceled.") return end - -- Expand and sanitize the project root path 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" - -- Debugging: Print paths - print("Creating project at:", project_root) + -- Debug: Print paths + print("Project root: " .. project_root) + print("Source directory: " .. src_dir) + print("Output directory: " .. out_dir) -- Create directories - local mkdir_status1 = vim.fn.mkdir(src_dir, "p") - local mkdir_status2 = vim.fn.mkdir(out_dir, "p") + vim.fn.mkdir(src_dir, "p") + vim.fn.mkdir(out_dir, "p") - -- Debugging: Check if directories were created - if not vim.loop.fs_stat(src_dir) or not vim.loop.fs_stat(out_dir) then - print("Error: Failed to create project directories.") - return - end - - -- Path for Main.java + -- Write Main.java local main_java_path = src_dir .. "/Main.java" local main_java_content = [[ public class Main { @@ -51,22 +49,19 @@ public class Main { } } ]] - - -- Attempt to write to the file - local file, err = io.open(main_java_path, "w") - if not file then - print("Error creating Main.java:", err) - return + local file = io.open(main_java_path, "w") + if file then + file:write(main_java_content) + file:close() + vim.cmd("edit " .. main_java_path) + print("Project '" .. project_name .. "' created at " .. project_root) + else + print("Error creating Main.java") end - file:write(main_java_content) - file:close() - - -- Open the new Java file - vim.cmd("edit " .. main_java_path) - print("Project '" .. project_name .. "' created at " .. project_root) end) end + -- Create a new Java file function M.create_new_file() vim.ui.input({ prompt = "Enter class name: " }, function(class_name) From 3d95d4c63a5e6fa5257ea469d5027e2530810eb9 Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:29:01 -0500 Subject: [PATCH 4/7] Update init.lua --- lua/Javanvim/init.lua | 60 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lua/Javanvim/init.lua b/lua/Javanvim/init.lua index dacdccd..487d24e 100644 --- a/lua/Javanvim/init.lua +++ b/lua/Javanvim/init.lua @@ -18,47 +18,47 @@ end -- Create a new Java project function M.create_project() - vim.ui.input({ prompt = "Enter project name: " }, function(project_name) - -- Debug: Print the project_name - print("Input received: " .. (project_name or "nil")) + local project_name = vim.fn.input("Enter project name: ") - if not project_name or project_name == "" then - print("Project creation canceled.") - return - end + -- Debug: Print the project_name + print("Input received: " .. (project_name or "nil")) - 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" + if not project_name or project_name == "" then + print("Project creation canceled.") + return + end - -- Debug: Print paths - print("Project root: " .. project_root) - print("Source directory: " .. src_dir) - print("Output directory: " .. out_dir) + 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" - -- Create directories - vim.fn.mkdir(src_dir, "p") - vim.fn.mkdir(out_dir, "p") + -- Debug: Print paths + print("Project root: " .. project_root) + print("Source directory: " .. src_dir) + print("Output directory: " .. out_dir) - -- Write Main.java - local main_java_path = src_dir .. "/Main.java" - local main_java_content = [[ + -- Create directories + vim.fn.mkdir(src_dir, "p") + vim.fn.mkdir(out_dir, "p") + + -- Write Main.java + local main_java_path = src_dir .. "/Main.java" + local main_java_content = [[ public class Main { public static void main(String[] args) { System.out.println("Hello, World!"); } } ]] - local file = io.open(main_java_path, "w") - if file then - file:write(main_java_content) - file:close() - vim.cmd("edit " .. main_java_path) - print("Project '" .. project_name .. "' created at " .. project_root) - else - print("Error creating Main.java") - end - end) + local file = io.open(main_java_path, "w") + if file then + file:write(main_java_content) + file:close() + vim.cmd("edit " .. main_java_path) + print("Project '" .. project_name .. "' created at " .. project_root) + else + print("Error creating Main.java") + end end 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 5/7] 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) From 60c60d3697c318109413c0109d003b359403881d Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:32:31 -0500 Subject: [PATCH 6/7] Update init.lua --- lua/Javanvim/init.lua | 72 +++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/lua/Javanvim/init.lua b/lua/Javanvim/init.lua index 9283f2a..461e426 100644 --- a/lua/Javanvim/init.lua +++ b/lua/Javanvim/init.lua @@ -18,38 +18,34 @@ end -- Create a new Java project function M.create_project() - -- Ensure the prompt is a string (to avoid invalid arguments) - local prompt = "Enter project name: " + -- Use vim.ui.input for better handling of input + vim.ui.input({ prompt = "Enter project name: " }, function(project_name) + -- Debugging: Output the input received + print("Input received: " .. (project_name or "nil")) - -- Use vim.fn.input to capture the input - local project_name = vim.fn.input(prompt) + -- Check if the project name is valid + if not project_name or project_name == "" then + print("Project creation canceled.") + return + end - -- Debugging: Output the input received - print("Input received: " .. (project_name or "nil")) + -- 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" - -- Check if the project name is valid - if not project_name or project_name == "" then - print("Project creation canceled.") - return - end + -- Debugging: Print the paths + print("Project root: " .. project_root) + print("Source directory: " .. src_dir) + print("Output directory: " .. out_dir) - -- 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" + -- Create directories + vim.fn.mkdir(src_dir, "p") + vim.fn.mkdir(out_dir, "p") - -- Debugging: Print the paths - print("Project root: " .. project_root) - print("Source directory: " .. src_dir) - print("Output directory: " .. out_dir) - - -- Create directories - vim.fn.mkdir(src_dir, "p") - vim.fn.mkdir(out_dir, "p") - - -- Write the Main.java file - local main_java_path = src_dir .. "/Main.java" - local main_java_content = [[ + -- Write the Main.java file + local main_java_path = src_dir .. "/Main.java" + local main_java_content = [[ public class Main { public static void main(String[] args) { System.out.println("Hello, World!"); @@ -57,19 +53,21 @@ 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) - file:close() - vim.cmd("edit " .. main_java_path) - print("Project '" .. project_name .. "' created at " .. project_root) - else - print("Error creating Main.java") - end + -- Create the file and write content + local file = io.open(main_java_path, "w") + if file then + file:write(main_java_content) + file:close() + vim.cmd("edit " .. main_java_path) + print("Project '" .. project_name .. "' created at " .. project_root) + else + print("Error creating Main.java") + end + end) end + -- Create a new Java file function M.create_new_file() vim.ui.input({ prompt = "Enter class name: " }, function(class_name) From 46b61c57ec5b4cc7e52d398f1972c7afe9f0a49e Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 19 Feb 2025 19:00:37 -0500 Subject: [PATCH 7/7] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f8ba2f2..dc47979 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Javanvim +Documentation is slowly going to move to [https://darthmoomancer.github.io/Javanvim.github.io/](https://darthmoomancer.github.io/Javanvim.github.io/) ## Why? The main goal is the plugin is to be simple and extensible for Java developers. Are there better plugins? Most likely, however this has simple functions for: