forked from emacs-lsp/dap-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dap-pwsh.el
82 lines (67 loc) · 3.2 KB
/
dap-pwsh.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
;;; dap-pwsh.el --- Debug Adapter Protocol mode for Pwsh -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Kien Nguyen
;; Author: Kien Nguyen <[email protected]>
;; Keywords: languages
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;; URL: https://github.com/yyoncho/dap-mode
;; Package-Requires: ((emacs "25.1") (lsp-mode "4.0") (dap-mode "0.2"))
;; Version: 0.2
;;; Commentary:
;;; Code:
(require 'dap-mode)
(require 'lsp-pwsh)
(require 'f)
(require 'dash)
(defgroup dap-pwsh nil
"Debugger support for PowerShell."
:group 'dap-mode
:package-version '(dap-mode . "0.2"))
(defcustom dap-pwsh-program
`(,lsp-pwsh-exe "-NoProfile" "-NonInteractive" "-NoLogo"
,@(if (eq system-type 'windows-nt) '("-ExecutionPolicy" "Bypass"))
"-OutputFormat" "Text"
"-File"
,(f-join lsp-pwsh-dir "PowerShellEditorServices/Start-EditorServices.ps1")
"-HostName" "'Emacs Host'"
"-HostProfileId" "'Emacs.LSP'"
"-HostVersion" "0.1"
"-LogPath" ,(f-join lsp-pwsh-log-path "emacs-powershell-debug.log")
"-LogLevel" ,lsp-pwsh-developer-editor-services-log-level
"-SessionDetailsPath"
,(format "%s/PSES-VSCode-%d-Debug" lsp-pwsh-log-path lsp-pwsh--sess-id)
;; "-AdditionalModules" "@('PowerShellEditorServices.VSCode')"
"-Stdio"
"-DebugServiceOnly"
"-BundledModulesPath" ,lsp-pwsh-dir
"-FeatureFlags" "@()")
"The command to run the pwsh debugger."
:group 'dap-pwsh
:type '(repeat string))
(defun dap-pwsh--populate-start-file-args (conf)
"Populate CONF with the required arguments."
(-> conf
(dap--put-if-absent :dap-server-path dap-pwsh-program)
(dap--put-if-absent :type "PowerShell")
(dap--put-if-absent :cwd (lsp-find-session-folder (lsp-session) (buffer-file-name)))
(dap--put-if-absent :script (read-file-name "Select the file to run:" nil (buffer-file-name) t))
(dap--put-if-absent :name "PowerShell: Debug")
(dap--put-if-absent :args [])))
(dap-register-debug-provider "PowerShell" #'dap-pwsh--populate-start-file-args)
(dap-register-debug-template "PowerShell: Launch Script"
(list :type "PowerShell"
:cwd nil
:request "launch"
:script nil
:args nil
:name "PowerShell: Launch Script"))
(provide 'dap-pwsh)
;;; dap-pwsh.el ends here