FEAT: adding create_project
This commit is contained in:
+17
-14
@@ -1,7 +1,18 @@
|
||||
local M = {}
|
||||
|
||||
---@param path string
|
||||
---@param content string
|
||||
function M.write_file(path, content)
|
||||
local file = assert(io.open(path, "w"), "Error creating file: " .. path)
|
||||
file:write(content)
|
||||
file:close()
|
||||
end
|
||||
|
||||
function M.interpolate(str, ctx)
|
||||
return (str:gsub("{([^}]+)}", ctx))
|
||||
end
|
||||
|
||||
---@param bufnr? integer Default is 0 (current buffer)
|
||||
---@return string|nil
|
||||
function M.get_project_root(bufnr)
|
||||
bufnr = bufnr or 0
|
||||
local root_markers = {
|
||||
@@ -15,6 +26,11 @@ function M.get_project_root(bufnr)
|
||||
return vim.fs.root(bufnr, root_markers) or vim.uv.cwd()
|
||||
end
|
||||
---
|
||||
---@return string
|
||||
function M.get_project_name()
|
||||
return vim.fn.fnamemodify(M.get_project_root(), ":t")
|
||||
end
|
||||
---
|
||||
---@param cmd table
|
||||
---@return integer, integer?
|
||||
function M.terminal(cmd, opts)
|
||||
@@ -106,20 +122,7 @@ return M
|
||||
-- end
|
||||
--
|
||||
--
|
||||
-- ---@return string
|
||||
-- function M.get_project_name()
|
||||
-- return vim.fn.fnamemodify(M.get_project_root(), ":t")
|
||||
-- end
|
||||
--
|
||||
-- ---@param path_segments table
|
||||
-- ---@param content string
|
||||
-- function M.write_file(path_segments, content)
|
||||
-- local path = table.concat(path_segments, "/")
|
||||
-- local file = assert(io.open(path, "w"), "Error creating file: " .. path)
|
||||
-- file:write(content)
|
||||
-- file:close()
|
||||
-- vim.cmd("edit " .. path)
|
||||
-- end
|
||||
--
|
||||
-- ---@param path string
|
||||
-- ---@param gitignore_lines table
|
||||
|
||||
Reference in New Issue
Block a user