42 lines
1.3 KiB
Lua
42 lines
1.3 KiB
Lua
local M = {}
|
|
|
|
local utils = require("vern.utils")
|
|
|
|
function M.create_project(opts) end
|
|
function M.create_file(opts) 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
|
|
function M.run(opts)
|
|
opts = opts or {}
|
|
local root = utils.get_project_root() or "."
|
|
local project_name = vim.fs.basename(root)
|
|
|
|
local exe = opts.python.templates.project.executable.target
|
|
or "src/%s/main.py"
|
|
local rel_path = exe:find("%%s") and string.format(exe, project_name) or exe
|
|
local full_path = root .. "/" .. rel_path
|
|
utils.terminal({ "python3 " .. full_path }, opts.terminal or {})
|
|
end
|
|
|
|
---@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.terminal({ "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
|
|
end
|
|
utils.terminal(
|
|
{ "pip install " .. vim.trim(pip_module) },
|
|
opts.terminal or {}
|
|
)
|
|
end)
|
|
end
|
|
|
|
return M
|