Cleanup util functions

This commit is contained in:
2023-09-02 21:51:20 +02:00
parent 172f0be68c
commit f8b940401a
3 changed files with 21 additions and 51 deletions
+7 -13
View File
@@ -16,35 +16,29 @@
local utils = require("utils")
M = {}
local M = {}
local env_ok = false
local dap = nil
local function check_env()
local debugpy = utils.exec("python -m debugpy --version")
assert(debugpy.rc == 0, "Python module debugpy is required")
local pytest = utils.exec("python -m pytest --version")
assert(pytest.rc == 0, "Python module pytest is required")
utils.exec("Asdf")
utils.assert_available("python3")
utils.assert_python3_module("debugpy")
utils.assert_python3_module("pytest")
env_ok = true
end
local function load_dap()
local ok, dap = pcall(require, "dap")
assert(ok, "nvim-dap is required")
return dap
end
function M.run(args)
assert(type(args) == "table", "Args not specified or of wrong type")
if not env_ok then
check_env()
end
if not dap then
dap = load_dap()
dap = require("dap")
dap.adapters.python = {
type = "executable",
command = "python",
command = "python3",
args = { "-m", "debugpy.adapter", },
cwd = vim.fn.getcwd(),
}