CHORE: Fixed bug #4 by looping dirs and creating directories before
other loops in creation. LANG: Added CPP and bugfixed c to use c code and not python
This commit is contained in:
+25
-18
@@ -19,7 +19,9 @@ function M.create_project(opts)
|
||||
---@type VernCConfig
|
||||
local cfg = vim.tbl_deep_extend("force", {}, configs, configs, opts or {})
|
||||
local root = join(vim.fn.expand(cfg.workspace_root), cfg.c.root, pname)
|
||||
local build_cmd = "cd " .. root .. " && cmake -S . -B build"
|
||||
local bin = action_utils.create(cfg.c, pname, root)
|
||||
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
||||
utils.init_git(root, "c")
|
||||
|
||||
vim.cmd.edit(vim.fn.fnameescape(bin))
|
||||
@@ -66,31 +68,36 @@ function M.create_file(opts)
|
||||
end)
|
||||
end
|
||||
|
||||
--- Goal is to add providers for uv and venv so its available to more users
|
||||
---@param opts? table Takes a table for the runtime
|
||||
---@param opts? VernCConfig Takes a table for the runtime
|
||||
function M.run(opts)
|
||||
opts = opts or {}
|
||||
local root = utils.proj_root() or "."
|
||||
local pname = vim.fs.basename(root)
|
||||
|
||||
local exe = opts.python.templates.project.bin.target or "src/%s/main.py"
|
||||
local full_path = join(vim.fn.expand(root), utils.fmt(exe, { project_name = pname }))
|
||||
utils.term({ "python3 " .. full_path }, opts.terminal or {})
|
||||
end
|
||||
local build_dir = root .. "/build"
|
||||
local build_cmd = "cd " .. build_dir .. " && cmake --build ."
|
||||
|
||||
---@param cmd_args? table Takes a table for the runtime
|
||||
function M.pip_install(opts, cmd_args)
|
||||
local args = cmd_args and cmd_args.args and vim.trim(cmd_args.args) or ""
|
||||
if args ~= "" then
|
||||
utils.term({ "pip install " .. args }, opts.terminal or {})
|
||||
return
|
||||
end
|
||||
vim.ui.input({ prompt = "Enter pip module: " }, function(pip_module)
|
||||
if not pip_module or vim.trim(pip_module) == "" then
|
||||
vim.notify("Pip Cancelled", vim.log.levels.WARN)
|
||||
return
|
||||
vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj)
|
||||
if obj.code ~= 0 then
|
||||
vim.schedule(function()
|
||||
local error_obj = (obj.stderr ~= "" and obj.stderr) or obj.stdout or ""
|
||||
local error_lines = vim.list_extend(
|
||||
{ "Error During compilation" },
|
||||
vim.split(error_obj, "\n", { trimempty = true })
|
||||
)
|
||||
local buf, _ = utils.term({ "echo 'compilation failed'" }, opts.terminal, true)
|
||||
if buf and vim.api.nvim_buf_is_valid(buf) then
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = buf })
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, error_lines)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = buf })
|
||||
end
|
||||
end)
|
||||
else
|
||||
vim.schedule(function()
|
||||
local run_cmd = "cd '" .. build_dir .. "' && ./" .. pname
|
||||
utils.term({ run_cmd }, opts.terminal, false)
|
||||
end)
|
||||
end
|
||||
utils.term({ "pip install " .. vim.trim(pip_module) }, opts.terminal or {})
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user