REFACTOR: Completely changed how project creation is done so I can make

other languages easier and hopefully faster
This commit is contained in:
2026-10-22 00:19:19 -04:00
parent df760783ba
commit 3bb97d833b
9 changed files with 347 additions and 105 deletions
+24 -9
View File
@@ -26,6 +26,24 @@ function M.proj_root(bufnr)
return vim.fs.root(bufnr, root_markers) or vim.uv.cwd()
end
---@param raw_path string Combination of tbl.path and tbl.name to override
---@param dir_tbl table<string, string> Strings to replace raw directories in {dirs.<>} with
---@param ctx table<string, string> Strings to replace raw names like {project_name} with
---@return string path Fully replaced path
function M.resolve_path(raw_path, dir_tbl, ctx)
--- Replace the {dirs.<key>}
raw_path = raw_path:gsub("{dirs%.([%w_]+)}", function(dir_key)
return dir_tbl and dir_tbl[dir_key] or dir_key
end)
--- Replace the {<key>}
local path = raw_path:gsub("{([%w_]+)}", function(key)
return ctx and ctx[key] or ("{" .. key .. "}")
end)
return path
end
---@return string
function M.proj_name()
return vim.fn.fnamemodify(M.proj_root(), ":t")
@@ -44,6 +62,12 @@ function M.init_git(path, ft)
M.dump(vim.fs.joinpath(path, ".gitignore"), gitignore)
end
---@param path string
function M.init_readme(path)
local readme = require("vern.templates.extras.readme")
M.dump(vim.fs.joinpath(path, "README.md"), readme)
end
---@param cmd table
---@return integer, integer?
function M.term(cmd, opts)
@@ -116,12 +140,3 @@ function M.term(cmd, opts)
end
return M
-- function M.exists(path)
-- return (io.open(path, "r") ~= nil)
-- end
--
--
--
--
-- return M