Files
vern-nvim/lua/vern/actions/python.lua
T
DarthMooMancer 98bd619cfa REFACTOR: Merged templates into a per language file, deleted init.lua as
it was just a middle man and wasnt needed (in fact it is better without
it)
FT: Changes to python
2026-10-15 23:32:26 -04:00

46 lines
1.3 KiB
Lua

local M = {}
local utils = require("vern.utils")
M.default_target_file = "main.py"
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 pattern = vim.tbl_get(
opts,
"templates",
"project",
"executable",
"target"
) or "src/%s/main.py"
local rel_path = pattern:find("%%s")
and string.format(pattern, project_name)
or pattern
local full_path = root .. "/" .. rel_path
utils.terminal({ "python3 " .. full_path }, opts)
end
---@param cmd_args? table Takes a table for the runtime
function M.pip_install(opts, cmd_args)
if cmd_args and cmd_args.args and cmd_args ~= "" then
utils.terminal({ "pip install " .. cmd_args.args })
return
end
vim.ui.input({ prompt = "Enter pip module: " }, function(pip_module)
if not pip_module or pip_module == "" then
vim.notify("Pip Cancelled", vim.log.levels.WARN)
return
end
utils.terminal({ "pip install " .. pip_module }, opts or {})
end)
end
return M