From d073ece621c698fa86f91051b362bd60c5b5b368 Mon Sep 17 00:00:00 2001 From: roc Date: Wed, 13 Sep 2023 22:04:07 +0800 Subject: [PATCH] fix(python): ensure debugpy installed if using nvim-dap --- lua/lazyvim/plugins/extras/lang/python.lua | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index e64decd1..01216d07 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -46,16 +46,25 @@ return { "mfussenegger/nvim-dap", optional = true, dependencies = { - "mfussenegger/nvim-dap-python", - -- stylua: ignore - keys = { - { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method" }, - { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class" }, + { + "mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "debugpy" }) + end, + }, + { + "mfussenegger/nvim-dap-python", + -- stylua: ignore + keys = { + { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method" }, + { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class" }, + }, + config = function() + local path = require("mason-registry").get_package("debugpy"):get_install_path() + require("dap-python").setup(path .. "/venv/bin/python") + end, }, - config = function() - local path = require("mason-registry").get_package("debugpy"):get_install_path() - require("dap-python").setup(path .. "/venv/bin/python") - end, }, }, {