rework: templates.files uses table instead of deprecated string format

rework: templates.files no longer requires the deprecated .polydev files
feat: added get_project_name to utils
This commit is contained in:
DarthMooMancer
2025-05-12 01:09:03 -04:00
parent 4ecaf54f82
commit 8584ed4bbf
2 changed files with 39 additions and 84 deletions
+19
View File
@@ -24,6 +24,11 @@ function M.get_project_root()
return dir
end
function M.get_project_name()
local root = M.get_project_root()
return vim.fn.fnamemodify(root, ":t")
end
function M.write_file(path_segments, content)
local path = table.concat(path_segments, "/")
local file = assert(io.open(path, "w"), "Error creating file: " .. path)
@@ -32,6 +37,20 @@ function M.write_file(path_segments, content)
vim.cmd("edit " .. path)
end
function M.init_git(path, gitignore_lines)
vim.fn.mkdir(path, "p")
-- Initialize Git
vim.fn.system({ "git", "-C", path, "init" })
-- Write .gitignore if provided
if gitignore_lines and #gitignore_lines > 0 then
local gitignore_path = { path, ".gitignore" }
local contents = table.concat(gitignore_lines, "\n")
M.write_file(gitignore_path, contents)
end
end
function M.open_float_terminal(cmd)
local presets = require("Polydev.presets")
local presets_opts = {}