Merge branch 'main' of https://github.com/DarthMooMancer/Javanvim
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# Javanvim
|
# Javanvim
|
||||||
|
|
||||||
|
Documentation is slowly going to move to [https://darthmoomancer.github.io/Javanvim.github.io/](https://darthmoomancer.github.io/Javanvim.github.io/)
|
||||||
## Why?
|
## 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:
|
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:
|
||||||
@@ -16,7 +17,7 @@ For Lazy.nvim:
|
|||||||
require {
|
require {
|
||||||
"DarthMooMancer/Javanvim",
|
"DarthMooMancer/Javanvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("Javavim").setup()
|
require("Javanvim").setup()
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
+16
-1
@@ -28,21 +28,32 @@ end
|
|||||||
|
|
||||||
-- Create a new Java project
|
-- Create a new Java project
|
||||||
function M.create_project()
|
function M.create_project()
|
||||||
|
-- Use vim.ui.input for better handling of input
|
||||||
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
||||||
|
-- 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
|
if not project_name or project_name == "" then
|
||||||
print("Project creation canceled.")
|
print("Project creation canceled.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Paths for the project
|
||||||
local project_root = vim.fn.expand(M.config.project_root) .. "/" .. project_name
|
local project_root = vim.fn.expand(M.config.project_root) .. "/" .. project_name
|
||||||
local src_dir = project_root .. "/root/src"
|
local src_dir = project_root .. "/root/src"
|
||||||
local out_dir = project_root .. "/root/out"
|
local out_dir = project_root .. "/root/out"
|
||||||
|
|
||||||
|
-- Debugging: Print the paths
|
||||||
|
print("Project root: " .. project_root)
|
||||||
|
print("Source directory: " .. src_dir)
|
||||||
|
print("Output directory: " .. out_dir)
|
||||||
|
|
||||||
-- Create directories
|
-- Create directories
|
||||||
vim.fn.mkdir(src_dir, "p")
|
vim.fn.mkdir(src_dir, "p")
|
||||||
vim.fn.mkdir(out_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_path = src_dir .. "/Main.java"
|
||||||
local main_java_content = [[
|
local main_java_content = [[
|
||||||
public class Main {
|
public class Main {
|
||||||
@@ -51,6 +62,8 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- Create the file and write content
|
||||||
local file = io.open(main_java_path, "w")
|
local file = io.open(main_java_path, "w")
|
||||||
if file then
|
if file then
|
||||||
file:write(main_java_content)
|
file:write(main_java_content)
|
||||||
@@ -63,6 +76,8 @@ public class Main {
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Create a new Java file
|
-- Create a new Java file
|
||||||
function M.create_new_file()
|
function M.create_new_file()
|
||||||
vim.ui.input({ prompt = "Enter class name: " }, function(class_name)
|
vim.ui.input({ prompt = "Enter class name: " }, function(class_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user