Skip to content

Commit

Permalink
feat: dap support out-of-the-box
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoP committed Nov 11, 2023
1 parent d097094 commit 12fcf61
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions lua/powershell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local default_config = {
on_attach = function() end,
capabilities = vim.lsp.protocol.make_client_capabilities(),
bundle_path = "",
init_options = {},
init_options = vim.empty_dict(),
settings = vim.empty_dict(),
shell = "pwsh",
}
Expand Down Expand Up @@ -99,6 +99,43 @@ M.config = default_config
---@param args powershell.config?
M.setup = function(args)
if args then M.config = vim.tbl_deep_extend("force", M.config, args) end

local ok, dap = pcall(require, "dap")
if ok then
dap.adapters.powershell = function(callback)
callback {
type = "pipe",
pipe = M._session_details.debugServicePipeName,
}
end
dap.configurations.ps1 = {
{
name = "PowerShell: Launch Current File",
type = "powershell",
request = "launch",
script = "${file}",
},
{
name = "PowerShell: Attach to PowerShell Host Process",
type = "powershell",
request = "attach",
runspaceId = 1,
},
{
name = "PowerShell: Run Pester Tests",
type = "powershell",
request = "launch",
script = "Invoke-Pester",
createTemporaryIntegratedConsole = true,
attachDotnetDebugger = true,
},
{
name = "PowerShell: Interactive Session",
type = "powershell",
request = "launch",
},
}
end
end

local temp_path = vim.fn.stdpath "cache"
Expand All @@ -119,7 +156,7 @@ local function make_cmd(bundle_path, shell)
"-HostVersion", "1.0.0",
"-LogPath", ("%s/powershell_es.log"):format(temp_path),
-- TODO: make this configurable
"-LogLevel", "Diagnostic",
"-LogLevel", "Normal",
"-BundledModulesPath", ("%s"):format(bundle_path),
"-EnableConsoleRepl",
"-SessionDetailsPath", session_file_path,
Expand Down

0 comments on commit 12fcf61

Please sign in to comment.