Skip to content

Commit 5f6a4c3

Browse files
committed
refactor(python): clean up nvim-dap-python implementation
1 parent 3cdde12 commit 5f6a4c3

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

lua/astrocommunity/pack/python/init.lua

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,22 @@ return {
101101
dependencies = "mfussenegger/nvim-dap",
102102
ft = "python", -- NOTE: ft: lazy-load on filetype
103103
config = function(_, opts)
104-
local path = function()
105-
local ret = nil
104+
local path
106105

107-
local ok, mason_registry = pcall(require, "mason-registry")
108-
if ok then
109-
local debugpy = mason_registry.get_package "debugpy"
110-
if debugpy:is_installed() then
111-
ret = vim.fn.expand "$MASON/packages/debugpy"
112-
if vim.fn.has "win32" == 1 then
113-
return ret .. "/venv/Scripts/python"
114-
else
115-
return ret .. "/venv/bin/python"
116-
end
117-
end
118-
end
119-
120-
ret = vim.fn.exepath "debugpy-adapter"
121-
if ret == "" then
122-
return vim.fn.exepath "python"
106+
local mason_registry_avail, mason_registry = pcall(require, "mason-registry")
107+
if mason_registry_avail and mason_registry.is_installed "debugpy" then
108+
path = vim.fn.expand "$MASON/packages/debugpy"
109+
if vim.fn.has "win32" == 1 then
110+
path = path .. "/venv/Scripts/python"
123111
else
124-
return ret
112+
path = path .. "/venv/bin/python"
125113
end
114+
else
115+
path = vim.fn.exepath "debugpy-adapter"
116+
if path == "" then path = vim.fn.exepath "python" end
126117
end
127-
require("dap-python").setup(path(), opts)
118+
119+
require("dap-python").setup(path, opts)
128120
end,
129121
},
130122
},

0 commit comments

Comments
 (0)