From 1e987bf5b6e39e971e0946b794f6f4d369a410c4 Mon Sep 17 00:00:00 2001 From: DarthMooMancer Date: Sun, 11 May 2025 09:07:03 -0400 Subject: [PATCH] feat: added git initalization to java as test for replacement to polydev files --- lua/Polydev/templates.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lua/Polydev/templates.lua b/lua/Polydev/templates.lua index 1b1bb44..7cb62b8 100644 --- a/lua/Polydev/templates.lua +++ b/lua/Polydev/templates.lua @@ -15,6 +15,21 @@ local M = {} ---@field html TemplateLanguage ---@alias TemplatesLanguageName "java" | "python" | "lua" | "c" | "cpp" | "rust" | "html" +local function init_git(path, gitignore_lines) + local full_path = vim.fn.expand(path) + vim.fn.mkdir(full_path, "p") + + -- Initialize Git + vim.fn.system({ "git", "-C", full_path, "init" }) + + -- Write .gitignore if provided + if gitignore_lines and #gitignore_lines > 0 then + local gitignore_path = full_path .. "/.gitignore" + local contents = table.concat(gitignore_lines, "\n") + utils.write_file(gitignore_path, contents) + end +end + ---@type Projects M.projects = { java = { @@ -28,6 +43,10 @@ public class Main { } } ]] + local java_gitignore = { + "build/" + } + init_git(full_project_root, java_gitignore) utils.write_file(full_project_root .. "/src/Main.java", main_java_content) return full_project_root end