diff --git a/dap-dlv-go.el b/dap-dlv-go.el index 8e0bb9a1..5fd6dc82 100644 --- a/dap-dlv-go.el +++ b/dap-dlv-go.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0") (f "0.20.0")) -;; Version: 0.1 - ;;; Commentary: ;; Adapter for https://github.com/go-delve/delve @@ -36,9 +32,9 @@ (defcustom dap-dlv-go-delve-path (or (executable-find "dlv") - (expand-file-name - "dlv" (expand-file-name "bin" (or (getenv "GOPATH") - (f-join (getenv "HOME") "go"))))) + (expand-file-name + "dlv" (expand-file-name "bin" (or (getenv "GOPATH") + (f-join (getenv "HOME") "go"))))) "The path to the delve command." :group 'dap-dlv-go :type 'string) @@ -55,67 +51,67 @@ (defun dap-dlv-go--populate-default-args (conf) "Populate CONF with the default arguments." (setq conf - (pcase (plist-get conf :mode) - ("auto" - (dap-dlv-go--populate-auto-args conf)) - ("test" - (dap-dlv-go--populate-test-args conf)) - ("debug" - (dap--put-if-absent - conf :program (f-dirname (buffer-file-name)))) - ("exec" - (dap--put-if-absent - conf :program - (f-expand (read-file-name "enter path to executable: ")))) - ("remote" - (dap--put-if-absent conf :host (read-string "enter host: " "127.0.0.1")) - (dap--put-if-absent conf :debugPort - (string-to-number (read-string "enter port: " "2345")))) - ("local" - (dap--put-if-absent conf :cwd (f-dirname (buffer-file-name))) - (dap--put-if-absent - conf :processId (string-to-number (read-string "enter pid: " "2345")))))) + (pcase (plist-get conf :mode) + ("auto" + (dap-dlv-go--populate-auto-args conf)) + ("test" + (dap-dlv-go--populate-test-args conf)) + ("debug" + (dap--put-if-absent + conf :program (f-dirname (buffer-file-name)))) + ("exec" + (dap--put-if-absent + conf :program + (f-expand (read-file-name "enter path to executable: ")))) + ("remote" + (dap--put-if-absent conf :host (read-string "enter host: " "127.0.0.1")) + (dap--put-if-absent conf :debugPort + (string-to-number (read-string "enter port: " "2345")))) + ("local" + (dap--put-if-absent conf :cwd (f-dirname (buffer-file-name))) + (dap--put-if-absent + conf :processId (string-to-number (read-string "enter pid: " "2345")))))) (when-let ((env-file (plist-get conf :envFile))) - (plist-put conf :env (dap-dlv-go--parse-env-file env-file))) + (plist-put conf :env (dap-dlv-go--parse-env-file env-file))) (let ((debug-port (if (string= (plist-get conf :mode) - "remote") - (plist-get conf :debugPort) - (dap--find-available-port)))) - (dap--put-if-absent conf :host "localhost") - (when (not (string= "remote" (plist-get conf :mode))) - (plist-put - conf :program-to-start - (format "%s dap --listen 127.0.0.1:%s %s" dap-dlv-go-delve-path debug-port dap-dlv-go-extra-args))) - (plist-put conf :debugServer debug-port)) + "remote") + (plist-get conf :debugPort) + (dap--find-available-port)))) + (dap--put-if-absent conf :host "localhost") + (when (not (string= "remote" (plist-get conf :mode))) + (plist-put + conf :program-to-start + (format "%s dap --listen 127.0.0.1:%s %s" dap-dlv-go-delve-path debug-port dap-dlv-go-extra-args))) + (plist-put conf :debugServer debug-port)) (if (stringp (plist-get conf :args)) (plist-put conf :args (split-string (plist-get conf :args))) ()) (when (string= (plist-get conf :name) "Test function") - (-when-let (name (dap-dlv-go--extract-current--method-or-function-name t)) - (dap--put-if-absent conf :args (list (format "-test.run=^%s$" name))))) + (-when-let (name (dap-dlv-go--extract-current--method-or-function-name t)) + (dap--put-if-absent conf :args (list (format "-test.run=^%s$" name))))) (when (string= (plist-get conf :name) "Test subtest") - (-when-let (name (concat - (dap-dlv-go--extract-current--method-or-function-name t) - "/" - (shell-quote-argument (dap-dlv-go--extract-current-subtest-name t)))) - (dap--put-if-absent conf :args (list (format "-test.run=^%s" name))))) + (-when-let (name (concat + (dap-dlv-go--extract-current--method-or-function-name t) + "/" + (shell-quote-argument (dap-dlv-go--extract-current-subtest-name t)))) + (dap--put-if-absent conf :args (list (format "-test.run=^%s" name))))) (-> conf - (dap--put-if-absent :dlvToolPath dap-dlv-go-delve-path) + (dap--put-if-absent :dlvToolPath dap-dlv-go-delve-path) - (dap--put-if-absent :type "go") - (dap--put-if-absent :name "Go Dlv Debug"))) + (dap--put-if-absent :type "go") + (dap--put-if-absent :name "Go Dlv Debug"))) (defun dap-dlv-go--populate-auto-args (conf) "Populate auto arguments according to CONF." (dap--put-if-absent conf :program (buffer-file-name)) (if (string-suffix-p "_test.go" (buffer-file-name)) - (plist-put conf :mode "test") - (plist-put conf :mode "debug"))) + (plist-put conf :mode "test") + (plist-put conf :mode "debug"))) (defun dap-dlv-go--populate-test-args (conf) "Populate auto arguments according to CONF." @@ -124,59 +120,59 @@ (defun dap-dlv-go--extract-current--method-or-function-name (&optional no-signal?) "Extract current method or function name." (let ((symbols (lsp--get-document-symbols))) - (or (->> symbols - (-keep - (-lambda ((&DocumentSymbol :kind :range :selection-range)) - (-let (((beg . end) (lsp--range-to-region range))) - (and (or (= lsp/symbol-kind-method kind) - (= lsp/symbol-kind-function kind)) - (<= beg (point) end) - (lsp-region-text selection-range))))) - (car)) - (unless no-signal? - (user-error "No method or function at point"))))) + (or (->> symbols + (-keep + (-lambda ((&DocumentSymbol :kind :range :selection-range)) + (-let (((beg . end) (lsp--range-to-region range))) + (and (or (= lsp/symbol-kind-method kind) + (= lsp/symbol-kind-function kind)) + (<= beg (point) end) + (lsp-region-text selection-range))))) + (car)) + (unless no-signal? + (user-error "No method or function at point"))))) (defun dap-dlv-go--extract-current-subtest-name (&optional no-signal?) "Extract current subtest name." (save-excursion - (save-restriction - (search-backward-regexp "^[[:space:]]*{" nil t) - (search-forward-regexp "name:[[:space:]]+[\"`]\\(.*\\)[\"`]\," nil t) - (or (match-string-no-properties 1) - (unless no-signal? - (user-error "No subtest at point")))))) + (save-restriction + (search-backward-regexp "^[[:space:]]*{" nil t) + (search-forward-regexp "name:[[:space:]]+[\"`]\\(.*\\)[\"`]\," nil t) + (or (match-string-no-properties 1) + (unless no-signal? + (user-error "No subtest at point")))))) (defun dap-dlv-go--parse-env-file (file) "Parse env FILE." (with-temp-buffer - (save-match-data - (find-file file) - (setq-local buffer-file-name nil) - (replace-regexp "[[:space:]]*#.*$" "" nil (point-min) (point-max)) - (let ((res (make-hash-table))) - (goto-char (point-min)) - (while (search-forward-regexp "\\(^[^=].*\\)=\\(.*\\)$" nil t) - (ht-set res (match-string 1) (match-string 2))) - (kill-buffer) - res)))) + (save-match-data + (find-file file) + (setq-local buffer-file-name nil) + (replace-regexp "[[:space:]]*#.*$" "" nil (point-min) (point-max)) + (let ((res (make-hash-table))) + (goto-char (point-min)) + (while (search-forward-regexp "\\(^[^=].*\\)=\\(.*\\)$" nil t) + (ht-set res (match-string 1) (match-string 2))) + (kill-buffer) + res)))) (defun dap-dlv-go--get-cmd-pid (cmd) "Return pid of CMD." (string-to-number (cadr - (s-split-words - (car - (seq-filter - (lambda(s) (s-contains? cmd s)) - (process-lines (executable-find "ps") "aux"))))))) + (s-split-words + (car + (seq-filter + (lambda(s) (s-contains? cmd s)) + (process-lines (executable-find "ps") "aux"))))))) (defun dap-dlv-go--run-cmd-in-vterm (cmd buf) "Run CMD with vterm in BUF." (with-current-buffer buf - (require 'vterm) - (let ((vterm-shell cmd) - (vterm-kill-buffer-on-exit nil)) - (vterm-mode)))) + (require 'vterm) + (let ((vterm-shell cmd) + (vterm-kill-buffer-on-exit nil)) + (vterm-mode)))) (defun dap-dlv-go--run-cmd-in-vterm-get-pid (cmd buf) "Run CMD in vterm inside BUF and return pid." @@ -188,80 +184,80 @@ With `C-u' you can edit command before run." (interactive) (let* ((exe (f-expand (read-file-name "enter path to executable: "))) - (cmd (if (equal (car current-prefix-arg) 4) - (read-string "command: " exe) - exe)) - (buf (generate-new-buffer - (format "*%s console*" - (f-base exe)))) - (debug-port (dap--find-available-port)) - (pid (dap-dlv-go--run-cmd-in-vterm-get-pid cmd buf))) - (dap-start-debugging-noexpand (list :type "go" - :request "attach" - :name "Attach to running process" - :mode "local" - :host "localhost" - :debugServer debug-port - :processId pid - :dlvToolPath dap-dlv-go-delve-path - :program-to-start - (format - "%s dap --listen 127.0.0.1:%s %s" - dap-dlv-go-delve-path - debug-port - dap-dlv-go-extra-args))) - (display-buffer buf) - (dap-ui--show-buffer buf))) + (cmd (if (equal (car current-prefix-arg) 4) + (read-string "command: " exe) + exe)) + (buf (generate-new-buffer + (format "*%s console*" + (f-base exe)))) + (debug-port (dap--find-available-port)) + (pid (dap-dlv-go--run-cmd-in-vterm-get-pid cmd buf))) + (dap-start-debugging-noexpand (list :type "go" + :request "attach" + :name "Attach to running process" + :mode "local" + :host "localhost" + :debugServer debug-port + :processId pid + :dlvToolPath dap-dlv-go-delve-path + :program-to-start + (format + "%s dap --listen 127.0.0.1:%s %s" + dap-dlv-go-delve-path + debug-port + dap-dlv-go-extra-args))) + (display-buffer buf) + (dap-ui--show-buffer buf))) (dap-register-debug-provider "go" 'dap-dlv-go--populate-default-args) (dap-register-debug-template "Go Dlv Launch File Configuration" - (list :type "go" - :request "launch" - :name "Launch File" - :mode "auto" - :program nil - :buildFlags nil - :args nil - :env nil)) + (list :type "go" + :request "launch" + :name "Launch File" + :mode "auto" + :program nil + :buildFlags nil + :args nil + :env nil)) (dap-register-debug-template "Go Dlv Attach Configuration" - (list :type "go" - :request "attach" - :name "Attach to running process" - :mode "auto")) + (list :type "go" + :request "attach" + :name "Attach to running process" + :mode "auto")) (dap-register-debug-template "Go Dlv Launch Executable Configuration" - (list :type "go" - :request "launch" - :name "Launch Executable" - :mode "exec" - :program nil - :args nil - :env nil)) + (list :type "go" + :request "launch" + :name "Launch Executable" + :mode "exec" + :program nil + :args nil + :env nil)) (dap-register-debug-template "Go Dlv Remote Debug" - (list :type "go" - :request "attach" - :name "Dlv Remote Debug" - :mode "remote")) + (list :type "go" + :request "attach" + :name "Dlv Remote Debug" + :mode "remote")) (dap-register-debug-template "Go Dlv Test Current Function Configuration" - (list :type "go" - :request "launch" - :name "Test function" - :mode "test" - :program nil - :args nil - :env nil)) + (list :type "go" + :request "launch" + :name "Test function" + :mode "test" + :program nil + :args nil + :env nil)) (dap-register-debug-template "Go Dlv Test Current Subtest Configuration" - (list :type "go" - :request "launch" - :name "Test subtest" - :mode "test" - :program nil - :args nil - :env nil)) + (list :type "go" + :request "launch" + :name "Test subtest" + :mode "test" + :program nil + :args nil + :env nil)) (provide 'dap-dlv-go) ;;; dap-dlv-go.el ends here diff --git a/dap-gdb-lldb.el b/dap-gdb-lldb.el index e0d41984..a2afc301 100644 --- a/dap-gdb-lldb.el +++ b/dap-gdb-lldb.el @@ -18,9 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Version: 0.2 - ;;; Commentary: ;; Adapter for https://github.com/WebFreak001/code-debug diff --git a/dap-gdscript.el b/dap-gdscript.el index ad00488a..e5b53186 100644 --- a/dap-gdscript.el +++ b/dap-gdscript.el @@ -36,22 +36,22 @@ (defun dap-gdscript--populate-start-file-args (conf) "Populate CONF with the required arguments." (let ((conf (-> conf - (dap--put-if-absent :host dap-gdscript-debug-host) - (dap--put-if-absent :debugServer dap-gdscript-debug-port) - (dap--put-if-absent :type "gdscript") - (dap--put-if-absent :cwd default-directory) - (dap--put-if-absent :name "Gdscript Debug") - (dap--put-if-absent :args "")))) - conf)) + (dap--put-if-absent :host dap-gdscript-debug-host) + (dap--put-if-absent :debugServer dap-gdscript-debug-port) + (dap--put-if-absent :type "gdscript") + (dap--put-if-absent :cwd default-directory) + (dap--put-if-absent :name "Gdscript Debug") + (dap--put-if-absent :args "")))) + conf)) (dap-register-debug-provider "gdscript" #'dap-gdscript--populate-start-file-args) (dap-register-debug-template "Gdscript Run Configuration" - (list :type "gdscript" - :cwd nil - :request "launch" - :program nil - :name "Gdscript::Run")) + (list :type "gdscript" + :cwd nil + :request "launch" + :program nil + :name "Gdscript::Run")) (provide 'dap-gdscript) ;;; dap-gdscript.el ends here diff --git a/dap-go.el b/dap-go.el index 16b2defd..69e4a672 100644 --- a/dap-go.el +++ b/dap-go.el @@ -33,20 +33,20 @@ (defcustom dap-go-debug-program `("node" - ,(let ((old (f-join dap-go-debug-path "extension/out/src/debugAdapter/goDebug.js")) - (new (f-join dap-go-debug-path "extension/dist/debugAdapter.js"))) - (if (f-exists? old) - (progn - (lsp--warn "Go debug adapter is outdated; some features will not work properly (map debugging).\n\ + ,(let ((old (f-join dap-go-debug-path "extension/out/src/debugAdapter/goDebug.js")) + (new (f-join dap-go-debug-path "extension/dist/debugAdapter.js"))) + (if (f-exists? old) + (progn + (lsp--warn "Go debug adapter is outdated; some features will not work properly (map debugging).\n\ Update `dap-go' using `C-u M-x dap-go-setup'") - old) - new))) + old) + new))) "The path to the go debugger." :group 'dap-go :type '(repeat string)) (defcustom dap-go-delve-path (or (executable-find "dlv") - (expand-file-name "dlv" (expand-file-name "bin" (getenv "GOPATH")))) + (expand-file-name "dlv" (expand-file-name "bin" (getenv "GOPATH")))) "The path to the delve command." :group 'dap-go :type 'string) @@ -56,96 +56,96 @@ Update `dap-go' using `C-u M-x dap-go-setup'") (defun dap-go--populate-default-args (conf) "Populate CONF with the default arguments." (lwarn '(dap-go) :warning - "`dap-go' is deprecated. Use `dap-dlv-go' instead. + "`dap-go' is deprecated. Use `dap-dlv-go' instead. See https://emacs-lsp.github.io/dap-mode/page/configuration/#go") (setq conf - (pcase (plist-get conf :mode) - ("auto" (dap-go--populate-auto-args conf)) - ("debug" (dap--put-if-absent conf :program (f-dirname (buffer-file-name)))) - ("exec" (dap--put-if-absent conf :program (read-file-name "enter full path to executable without tilde:"))) - ("remote" (dap--put-if-absent conf :program (f-dirname (buffer-file-name))) - (dap--put-if-absent conf :host (read-string "enter host:" "127.0.0.1")) - (dap--put-if-absent conf :port (string-to-number (read-string "Enter port: " "2345")))) - ("local" - (dap--put-if-absent conf :cwd (f-dirname (buffer-file-name))) - (dap--put-if-absent conf :processId (string-to-number (read-string "Enter pid: " "2345")))))) + (pcase (plist-get conf :mode) + ("auto" (dap-go--populate-auto-args conf)) + ("debug" (dap--put-if-absent conf :program (f-dirname (buffer-file-name)))) + ("exec" (dap--put-if-absent conf :program (read-file-name "enter full path to executable without tilde:"))) + ("remote" (dap--put-if-absent conf :program (f-dirname (buffer-file-name))) + (dap--put-if-absent conf :host (read-string "enter host:" "127.0.0.1")) + (dap--put-if-absent conf :port (string-to-number (read-string "Enter port: " "2345")))) + ("local" + (dap--put-if-absent conf :cwd (f-dirname (buffer-file-name))) + (dap--put-if-absent conf :processId (string-to-number (read-string "Enter pid: " "2345")))))) (if (stringp (plist-get conf :args)) (plist-put conf :args (split-string (plist-get conf :args))) ()) (-> conf - (dap--put-if-absent :dap-server-path dap-go-debug-program) - (dap--put-if-absent :dlvToolPath dap-go-delve-path) - (dap--put-if-absent :packagePathToGoModPathMap - (ht<-alist `((,(f-dirname (buffer-file-name)) . ,(lsp-find-session-folder (lsp-session) (buffer-file-name)))))) - (dap--put-if-absent :type "go") - (dap--put-if-absent :name "Go Debug"))) + (dap--put-if-absent :dap-server-path dap-go-debug-program) + (dap--put-if-absent :dlvToolPath dap-go-delve-path) + (dap--put-if-absent :packagePathToGoModPathMap + (ht<-alist `((,(f-dirname (buffer-file-name)) . ,(lsp-find-session-folder (lsp-session) (buffer-file-name)))))) + (dap--put-if-absent :type "go") + (dap--put-if-absent :name "Go Debug"))) (defun dap-go--populate-auto-args (conf) "Populate auto arguments." (dap--put-if-absent conf :program (buffer-file-name)) (if (string-suffix-p "_test.go" (buffer-file-name)) - (plist-put conf :mode "test") - (plist-put conf :mode "debug"))) + (plist-put conf :mode "test") + (plist-put conf :mode "debug"))) (dap-register-debug-provider "go" 'dap-go--populate-default-args) (dap-register-debug-template "Go Launch File Configuration" - (list :type "go" - :request "launch" - :name "Launch File" - :mode "auto" - :program nil - :buildFlags nil - :args nil - :env nil - :envFile nil)) + (list :type "go" + :request "launch" + :name "Launch File" + :mode "auto" + :program nil + :buildFlags nil + :args nil + :env nil + :envFile nil)) (dap-register-debug-template "Go Launch Debug Package Configuration" - (list :type "go" - :request "launch" - :name "Launch Debug Package" - :mode "debug" - :program nil - :buildFlags nil - :args nil - :env nil - :envFile nil)) + (list :type "go" + :request "launch" + :name "Launch Debug Package" + :mode "debug" + :program nil + :buildFlags nil + :args nil + :env nil + :envFile nil)) (dap-register-debug-template "Go Launch Unoptimized Debug Package Configuration" - (list :type "go" - :request "launch" - :name "Launch Unoptimized Debug Package" - :mode "debug" - :program nil - :buildFlags "-gcflags '-N -l'" - :args nil - :env nil - :envFile nil)) + (list :type "go" + :request "launch" + :name "Launch Unoptimized Debug Package" + :mode "debug" + :program nil + :buildFlags "-gcflags '-N -l'" + :args nil + :env nil + :envFile nil)) (dap-register-debug-template "Go Launch Executable Configuration" - (list :type "go" - :request "launch" - :name "Launch Executable" - :mode "exec" - :program nil - :args nil - :env nil - :envFile nil)) + (list :type "go" + :request "launch" + :name "Launch Executable" + :mode "exec" + :program nil + :args nil + :env nil + :envFile nil)) (dap-register-debug-template "Go Attach Executable Configuration" - (list :type "go" - :request "attach" - :name "Attach to Executable" - :mode "local" - :program nil - :args nil - :env nil - :envFile nil)) + (list :type "go" + :request "attach" + :name "Attach to Executable" + :mode "local" + :program nil + :args nil + :env nil + :envFile nil)) (dap-register-debug-template "Go Connect Remote dlv Configuration" - (list :type "go" - :request "launch" - :name "Connect to Remote dlv" - :mode "remote" - :program nil - :args nil - :env nil - :envFile nil)) + (list :type "go" + :request "launch" + :name "Connect to Remote dlv" + :mode "remote" + :program nil + :args nil + :env nil + :envFile nil)) (provide 'dap-go) ;;; dap-go.el ends here diff --git a/dap-netcore.el b/dap-netcore.el index 7f1512fa..b76d9ee5 100644 --- a/dap-netcore.el +++ b/dap-netcore.el @@ -45,84 +45,84 @@ with libxml2 support." "Update netcoredbg." (interactive) (let ((backup (concat dap-netcore-install-dir ".old"))) - (when (f-exists-p dap-netcore-install-dir) - (f-move dap-netcore-install-dir backup)) - (condition-case err - (dap-netcore--debugger-install) - (error (f-move backup dap-netcore-install-dir) - (signal (car err) (cdr err))) - (:success (when (f-exists-p backup) - (f-delete backup t)))))) + (when (f-exists-p dap-netcore-install-dir) + (f-move dap-netcore-install-dir backup)) + (condition-case err + (dap-netcore--debugger-install) + (error (f-move backup dap-netcore-install-dir) + (signal (car err) (cdr err))) + (:success (when (f-exists-p backup) + (f-delete backup t)))))) (defun dap-netcore--debugger-install () "Download the latest version of netcoredbg and extract it to `dap-netcore-install-dir'." (let* ((temp-file (make-temp-file "netcoredbg" nil - (if (eq system-type 'windows-nt) - ".zip" - ".tar.gz"))) - (install-dir-full (expand-file-name dap-netcore-install-dir)) - (unzip-script (pcase system-type - (`windows-nt (format "powershell -noprofile -noninteractive -nologo -ex bypass Expand-Archive -path '%s' -dest '%s'" temp-file install-dir-full)) - ((or `gnu/linux `darwin) (format "mkdir -p %s && tar xvzf %s -C %s" dap-netcore-install-dir temp-file dap-netcore-install-dir)) - (_ (user-error (format "Unable to extract server - file %s cannot be extracted, please extract it manually" temp-file)))))) - (if (and (not dap-netcore-download-url) - (fboundp 'libxml-available-p) - (fboundp 'dom-search) - (fboundp 'dom-attr)) - (url-retrieve "https://github.com/Samsung/netcoredbg/releases" - (lambda (_) - (setq dap-netcore-download-url - (concat - "https://github.com" - (dom-attr - (dom-search - (if (libxml-available-p) - (libxml-parse-html-region (point-min) (point-max)) - (xml-parse-region (point-min) (point-max))) - (lambda (node) - (string-match-p (pcase system-type - (`gnu/linux (if (string-match-p system-configuration ".*arm") - ".*linux-arm64\\.tar\\.gz" - ".*linux-amd64\\.tar\\.gz")) - (`darwin ".*osx.*\\.tar\\.gz") - (`windows-nt ".*win64.*\\.zip")) - (or (dom-attr node 'href) "")))) - 'href))) - (lsp-download-install - (lambda (&rest _) - (shell-command unzip-script)) - (lambda (error &rest _) - (user-error "Error during netcoredbg downloading: %s" error)) - :url dap-netcore-download-url - :store-path temp-file))) - (if dap-netcore-download-url - (lsp-download-install - (lambda (&rest _) - (shell-command unzip-script)) - (lambda (error &rest _) - (user-error "Error during netcoredbg downloading: %s" error)) - :url dap-netcore-download-url - :store-path temp-file) - (user-error "`dap-netcore-download-url' is not set. You can customize it"))))) + (if (eq system-type 'windows-nt) + ".zip" + ".tar.gz"))) + (install-dir-full (expand-file-name dap-netcore-install-dir)) + (unzip-script (pcase system-type + (`windows-nt (format "powershell -noprofile -noninteractive -nologo -ex bypass Expand-Archive -path '%s' -dest '%s'" temp-file install-dir-full)) + ((or `gnu/linux `darwin) (format "mkdir -p %s && tar xvzf %s -C %s" dap-netcore-install-dir temp-file dap-netcore-install-dir)) + (_ (user-error (format "Unable to extract server - file %s cannot be extracted, please extract it manually" temp-file)))))) + (if (and (not dap-netcore-download-url) + (fboundp 'libxml-available-p) + (fboundp 'dom-search) + (fboundp 'dom-attr)) + (url-retrieve "https://github.com/Samsung/netcoredbg/releases" + (lambda (_) + (setq dap-netcore-download-url + (concat + "https://github.com" + (dom-attr + (dom-search + (if (libxml-available-p) + (libxml-parse-html-region (point-min) (point-max)) + (xml-parse-region (point-min) (point-max))) + (lambda (node) + (string-match-p (pcase system-type + (`gnu/linux (if (string-match-p system-configuration ".*arm") + ".*linux-arm64\\.tar\\.gz" + ".*linux-amd64\\.tar\\.gz")) + (`darwin ".*osx.*\\.tar\\.gz") + (`windows-nt ".*win64.*\\.zip")) + (or (dom-attr node 'href) "")))) + 'href))) + (lsp-download-install + (lambda (&rest _) + (shell-command unzip-script)) + (lambda (error &rest _) + (user-error "Error during netcoredbg downloading: %s" error)) + :url dap-netcore-download-url + :store-path temp-file))) + (if dap-netcore-download-url + (lsp-download-install + (lambda (&rest _) + (shell-command unzip-script)) + (lambda (error &rest _) + (user-error "Error during netcoredbg downloading: %s" error)) + :url dap-netcore-download-url + :store-path temp-file) + (user-error "`dap-netcore-download-url' is not set. You can customize it"))))) (defun dap-netcore--debugger-cmd () "The location of the netcoredbg executable." (let ((file-ext (pcase system-type - (`windows-nt ".exe") - (_ "")))) - (or - (executable-find "netcoredbg") - (expand-file-name (concat "netcoredbg" file-ext) (f-join dap-netcore-install-dir "netcoredbg"))))) + (`windows-nt ".exe") + (_ "")))) + (or + (executable-find "netcoredbg") + (expand-file-name (concat "netcoredbg" file-ext) (f-join dap-netcore-install-dir "netcoredbg"))))) (defun dap-netcore--debugger-locate-or-install () "Return the location of netcoredbg." (let ((dbg (dap-netcore--debugger-cmd))) - (unless (file-exists-p dbg) - (if (yes-or-no-p "Netcoredbg is not installed. Do you want to install it?") - (dap-netcore--debugger-install) - (error "Cannot start debugger configuration without netcoredbg"))) - dbg)) + (unless (file-exists-p dbg) + (if (yes-or-no-p "Netcoredbg is not installed. Do you want to install it?") + (dap-netcore--debugger-install) + (error "Cannot start debugger configuration without netcoredbg"))) + dbg)) (defun dap-netcore--locate-dominating-file-wildcard (file name) "Starting at FILE, look up directory hierarchy for directory containing NAME. @@ -138,62 +138,62 @@ the function needs to examine, starting with FILE." ;; `name' in /home or in /. (setq file (abbreviate-file-name (expand-file-name file))) (let ((root nil) - try) - (while (not (or root - (null file) - (string-match locate-dominating-stop-dir-regexp file))) - (setq try (if (stringp name) - (and (file-directory-p file) - (file-expand-wildcards (f-join file name))) - (funcall name file))) - (cond (try (setq root file)) - ((equal file (setq file (file-name-directory - (directory-file-name file)))) - (setq file nil)))) - (if root (file-name-as-directory root)))) + try) + (while (not (or root + (null file) + (string-match locate-dominating-stop-dir-regexp file))) + (setq try (if (stringp name) + (and (file-directory-p file) + (file-expand-wildcards (f-join file name))) + (funcall name file))) + (cond (try (setq root file)) + ((equal file (setq file (file-name-directory + (directory-file-name file)))) + (setq file nil)))) + (if root (file-name-as-directory root)))) (defun dap-netcore--populate-args (conf) "Populate CONF with arguments to launch or attach netcoredbg." (dap--put-if-absent conf :dap-server-path (list (dap-netcore--debugger-locate-or-install) "--interpreter=vscode")) (pcase (plist-get conf :mode) - ("launch" - (dap--put-if-absent - conf - :program - (let ((project-dir (f-full - (or - (dap-netcore--locate-dominating-file-wildcard - default-directory "*.*proj") - (lsp-workspace-root))))) - (save-mark-and-excursion - (find-file (concat (f-slash project-dir) "*.*proj") t) - (let ((res (if (libxml-available-p) - (libxml-parse-xml-region (point-min) (point-max)) - (xml-parse-region (point-min) (point-max))))) - (kill-buffer) - (f-join project-dir "bin" "Debug" - (dom-text (dom-by-tag res 'TargetFramework)) - (dom-text (dom-by-tag res 'RuntimeIdentifier)) - (concat (car (-take-last 1 (f-split project-dir))) ".dll"))))))) - ("attach" - (dap--put-if-absent conf :processId (string-to-number (read-string "Enter PID: " "2345")))))) + ("launch" + (dap--put-if-absent + conf + :program + (let ((project-dir (f-full + (or + (dap-netcore--locate-dominating-file-wildcard + default-directory "*.*proj") + (lsp-workspace-root))))) + (save-mark-and-excursion + (find-file (concat (f-slash project-dir) "*.*proj") t) + (let ((res (if (libxml-available-p) + (libxml-parse-xml-region (point-min) (point-max)) + (xml-parse-region (point-min) (point-max))))) + (kill-buffer) + (f-join project-dir "bin" "Debug" + (dom-text (dom-by-tag res 'TargetFramework)) + (dom-text (dom-by-tag res 'RuntimeIdentifier)) + (concat (car (-take-last 1 (f-split project-dir))) ".dll"))))))) + ("attach" + (dap--put-if-absent conf :processId (string-to-number (read-string "Enter PID: " "2345")))))) (dap-register-debug-provider "coreclr" 'dap-netcore--populate-args) (dap-register-debug-template ".Net Core Attach (Console)" - (list :type "coreclr" - :request "attach" - :mode "attach" - :name "NetCoreDbg::Attach")) + (list :type "coreclr" + :request "attach" + :mode "attach" + :name "NetCoreDbg::Attach")) (dap-register-debug-template ".Net Core Launch (Console)" - (list :type "coreclr" - :request "launch" - :mode "launch" - :name "NetCoreDbg::Launch" - :dap-compilation "dotnet build")) + (list :type "coreclr" + :request "launch" + :mode "launch" + :name "NetCoreDbg::Launch" + :dap-compilation "dotnet build")) (provide 'dap-netcore) ;;; dap-netcore.el ends here diff --git a/dap-node.el b/dap-node.el index 3760c7c1..666b96ad 100644 --- a/dap-node.el +++ b/dap-node.el @@ -18,23 +18,19 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.2 - ;;; Code: (require 'dap-mode) (require 'dap-utils) (defcustom dap-node-debug-path (expand-file-name "vscode/ms-vscode.node-debug2" - dap-utils-extension-path) + dap-utils-extension-path) "The path to node vscode extension." :group 'dap-node :type 'string) (defcustom dap-node-debug-program `("node" - ,(f-join dap-node-debug-path "extension/out/src/nodeDebug.js")) + ,(f-join dap-node-debug-path "extension/out/src/nodeDebug.js")) "The path to the node debugger." :group 'dap-node :type '(repeat string)) diff --git a/dap-ocaml.el b/dap-ocaml.el index 4ae19337..b7814c21 100644 --- a/dap-ocaml.el +++ b/dap-ocaml.el @@ -18,10 +18,6 @@ ;; 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") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.2 - ;;; Commentary: ;; Adapter for OCaml Earlybird (https://github.com/hackwaly/ocamlearlybird) diff --git a/dap-overlays.el b/dap-overlays.el index 593334a5..c50d646f 100644 --- a/dap-overlays.el +++ b/dap-overlays.el @@ -16,10 +16,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see <http://www.gnu.org/licenses/>. -;; URL: https://github.com/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1")) -;; Version: 0.2 - ;;; Commentary: ;; Use `dap-overlays--make-overlay' to place a generic overlay at point. Or use ;; `dap-overlays--make-result-overlay' to place an interactive eval result overlay at @@ -113,9 +109,9 @@ This function also removes itself from `post-command-hook'." (add-hook 'post-command-hook #'dap-overlays--remove-result-overlay nil 'local)) (cl-defun dap-overlays--make-result-overlay (value &rest props &key where duration (type 'result) - (format (concat " " dap-overlays-eval-result-prefix "%s ")) - (prepend-face 'dap-result-overlay-face) - &allow-other-keys) + (format (concat " " dap-overlays-eval-result-prefix "%s ")) + (prepend-face 'dap-result-overlay-face) + &allow-other-keys) "Place an overlay displaying VALUE at the end of line. VALUE is used as the overlay's after-string property, meaning it is displayed at the end of the overlay. The overlay itself is placed from diff --git a/dap-php.el b/dap-php.el index 5ddec242..38c2e4a2 100644 --- a/dap-php.el +++ b/dap-php.el @@ -19,10 +19,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.2 - ;;; Commentary: ;; Adapter for https://github.com/felixfbecker/vscode-php-debug diff --git a/dap-pwsh.el b/dap-pwsh.el index 9da68a3e..76f0b097 100644 --- a/dap-pwsh.el +++ b/dap-pwsh.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (lsp-mode "4.0") (dap-mode "0.2")) -;; Version: 0.2 - ;;; Commentary: ;;; Code: diff --git a/dap-python.el b/dap-python.el index 25688c23..84e8a367 100644 --- a/dap-python.el +++ b/dap-python.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.2 - ;;; Commentary: ;; Adapter for ptvsd (https://github.com/Microsoft/ptvsd) @@ -89,9 +85,9 @@ https://github.com/pyenv/pyenv-which-ext." ((&DocumentSymbol :name :kind :range (&Range :start (&Position :line start-line - :character start-character) - :end (&Position :line end-line - :character end-character)))) + :character start-character) + :end (&Position :line end-line + :character end-character)))) (make-dap-python--symbol :name name :type (alist-get kind lsp-symbol-kinds) diff --git a/dap-ruby.el b/dap-ruby.el index 0a3e2fc3..90a455ee 100644 --- a/dap-ruby.el +++ b/dap-ruby.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.2 - ;;; Commentary: ;; Adapter for https://github.com/rubyide/vscode-ruby diff --git a/dap-swi-prolog.el b/dap-swi-prolog.el index 55a456dc..577ae7f9 100644 --- a/dap-swi-prolog.el +++ b/dap-swi-prolog.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.3 - ;;; Commentary: ;; Adapter for https://www.swi-prolog.org @@ -30,7 +26,7 @@ (require 'dap-mode) (defcustom dap-swi-prolog-debug-program - '("swipl" "-g" "[library(debug_adapter/main)]" "-t" "halt") + '("swipl" "-g" "[library(debug_adapter/main)]" "-t" "halt") "The path to the SWI-Prolog debug adapter." :group 'dap-swi-prolog :type '(repeat string)) diff --git a/dap-tasks.el b/dap-tasks.el index 9344a84f..d036a76e 100644 --- a/dap-tasks.el +++ b/dap-tasks.el @@ -105,22 +105,22 @@ The order of presedence within vscode is: (defun dap-tasks-configuration-get-depends (conf) "Given a debug CONF, get an ordered list of all the dependant tasks." (cl-labels ((loop-fn (confs tasks) - "Loop through TASKS to find all dependants." - (-when-let* ((deps (-mapcat (lambda (task) - (-if-let* (((&plist :dependsOn) task)) - (if (stringp dependsOn) - (loop-fn - (list (dap-tasks-get-configuration-by-label dependsOn)) - (append (list (dap-tasks-get-configuration-by-label dependsOn)) tasks)) - (loop-fn - (cl-map 'list #'dap-tasks-get-configuration-by-label (append dependsOn nil)) - (append (cl-map 'list #'dap-tasks-get-configuration-by-label (append dependsOn nil)) tasks))) - task)) - confs))) - (cl-remove-duplicates - (append deps tasks) - :test (lambda (lhs rhs) - (string= (plist-get lhs :label) (plist-get rhs :label))))))) + "Loop through TASKS to find all dependants." + (-when-let* ((deps (-mapcat (lambda (task) + (-if-let* (((&plist :dependsOn) task)) + (if (stringp dependsOn) + (loop-fn + (list (dap-tasks-get-configuration-by-label dependsOn)) + (append (list (dap-tasks-get-configuration-by-label dependsOn)) tasks)) + (loop-fn + (cl-map 'list #'dap-tasks-get-configuration-by-label (append dependsOn nil)) + (append (cl-map 'list #'dap-tasks-get-configuration-by-label (append dependsOn nil)) tasks))) + task)) + confs))) + (cl-remove-duplicates + (append deps tasks) + :test (lambda (lhs rhs) + (string= (plist-get lhs :label) (plist-get rhs :label))))))) (-filter #'listp (loop-fn `(,conf) `(,conf))))) (defun dap-tasks-configuration-prepend-name (conf) diff --git a/dap-ui.el b/dap-ui.el index 8098224d..4eea6cb1 100644 --- a/dap-ui.el +++ b/dap-ui.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (tree-mode "1.1.1.1") (bui "1.1.0")) -;; Version: 0.2 - ;;; Commentary: ;; DAP Windows/overlays @@ -447,15 +443,15 @@ DEBUG-SESSION is the debug session triggering the event." 'point (cl-second file-data))) (bui-define-interface dap-ui-breakpoints-ui list - :buffer-name "*Breakpoints*" - :get-entries-function 'dap-ui--breakpoints-entries - :format '((file-name dap-ui--get-file-info 30 t) - (line nil 8 bui-list-sort-numerically-2) - (verified nil 8 t) - (condition nil 25 t) - (hit-condition nil 20 t) - (log-message nil 15 t)) - :sort-key '(file-name)) + :buffer-name "*Breakpoints*" + :get-entries-function 'dap-ui--breakpoints-entries + :format '((file-name dap-ui--get-file-info 30 t) + (line nil 8 bui-list-sort-numerically-2) + (verified nil 8 t) + (condition nil 25 t) + (hit-condition nil 20 t) + (log-message nil 15 t)) + :sort-key '(file-name)) (defun dap-ui-breakpoints-goto () "Go to breakpoint under cursor." @@ -645,32 +641,32 @@ DEBUG-SESSION is the debug session triggering the event." (treemacs-pulse-on-failure "No node at point")))) (dap-ui-define-action dap-ui-session-select (:session) - (dap--switch-to-session session)) + (dap--switch-to-session session)) (dap-ui-define-action dap-ui-thread-select (:session :thread-id) - (setf (dap--debug-session-thread-id session) thread-id) - (dap--switch-to-session session) - (dap--select-thread-id session thread-id)) + (setf (dap--debug-session-thread-id session) thread-id) + (dap--switch-to-session session) + (dap--select-thread-id session thread-id)) (dap-ui-define-action dap-ui-delete-session (:session) - (dap-delete-session session)) + (dap-delete-session session)) (dap-ui-define-action dap-ui-disconnect (:session) - (dap-disconnect session)) + (dap-disconnect session)) (dap-ui-define-action dap-ui-continue (:session :thread-id) - (dap-continue session thread-id)) + (dap-continue session thread-id)) (dap-ui-define-action dap-ui-restart-frame (:session :stack-frame) - (dap-restart-frame session (gethash "id" stack-frame))) + (dap-restart-frame session (gethash "id" stack-frame))) (dap-ui-define-action dap-ui-select-stack-frame (:session :thread-id :stack-frame) - (setf (dap--debug-session-thread-id session) thread-id - (dap--debug-session-active-frame session) stack-frame) - (dap--switch-to-session session)) + (setf (dap--debug-session-thread-id session) thread-id + (dap--debug-session-active-frame session) stack-frame) + (dap--switch-to-session session)) (dap-ui-define-action dap-ui-thread-stop (:session :thread-id) - (dap-stop-thread-1 session thread-id)) + (dap-stop-thread-1 session thread-id)) (defvar dap-ui-session-mode-map (-doto (make-sparse-keymap) @@ -840,13 +836,13 @@ array variables." :type 'number) (dap-ui-define-action dap-ui-set-variable-value (:session :variables-reference :value :name) - (dap--send-message - (dap--make-request "setVariable" - (list :variablesReference variables-reference - :name name - :value (read-string (format "Enter value for %s: " name ) value))) - (dap--resp-handler) - session)) + (dap--send-message + (dap--make-request "setVariable" + (list :variablesReference variables-reference + :name name + :value (read-string (format "Enter value for %s: " name ) value))) + (dap--resp-handler) + session)) (defun dap-ui-render-variables (debug-session variables-reference &optional indexed-variables named-variables _node) "Render hierarchical variables for treemacs. @@ -1032,7 +1028,7 @@ request." (dap-ui-expressions-refresh)) (dap-ui-define-action dap-ui-expressions-mouse-remove (:expression) - (dap-ui-expressions-remove expression)) + (dap-ui-expressions-remove expression)) (defun dap-ui-expressions-refresh () (interactive) @@ -1128,34 +1124,34 @@ request." (defvar dap-exception-breakpoints nil) (dap-ui-define-action dap-ui-breakpoints-toggle (:filter :session :default) - (let ((type (plist-get (dap--debug-session-launch-args session) :type))) - (setf (alist-get - filter - (alist-get type dap-exception-breakpoints nil nil #'string=) - nil nil #'string=) - (not (dap--breakpoint-filter-enabled - filter - type - default)))) - (dap--set-exception-breakpoints session #'dap-ui-breakpoints--refresh)) + (let ((type (plist-get (dap--debug-session-launch-args session) :type))) + (setf (alist-get + filter + (alist-get type dap-exception-breakpoints nil nil #'string=) + nil nil #'string=) + (not (dap--breakpoint-filter-enabled + filter + type + default)))) + (dap--set-exception-breakpoints session #'dap-ui-breakpoints--refresh)) (dap-ui-define-action dap-ui-breakpoints-goto-breakpoint (:file-name :point) - (select-window (get-mru-window (selected-frame) nil)) - (find-file file-name) - (goto-char point)) + (select-window (get-mru-window (selected-frame) nil)) + (find-file file-name) + (goto-char point)) (dap-ui-define-action dap-ui-breakpoint-delete (:file-name :breakpoint) - (with-current-buffer (find-file-noselect file-name) - (dap-breakpoint-delete breakpoint file-name))) + (with-current-buffer (find-file-noselect file-name) + (dap-breakpoint-delete breakpoint file-name))) (dap-ui-define-action dap-ui-breakpoint-condition (:file-name :breakpoint) - (dap-breakpoint-condition file-name breakpoint)) + (dap-breakpoint-condition file-name breakpoint)) (dap-ui-define-action dap-ui-breakpoint-hit-condition (:file-name :breakpoint) - (dap-breakpoint-hit-condition file-name breakpoint)) + (dap-breakpoint-hit-condition file-name breakpoint)) (dap-ui-define-action dap-ui-breakpoint-log-message (:file-name :breakpoint) - (dap-breakpoint-log-message file-name breakpoint)) + (dap-breakpoint-log-message file-name breakpoint)) (defun dap-ui--breakpoints-data () (-let (((debug-session &as &dap-session 'launch-args 'current-capabilities 'breakpoints all-session-breakpoints) diff --git a/dap-unity.el b/dap-unity.el index 35e53e87..6dfbf161 100644 --- a/dap-unity.el +++ b/dap-unity.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.2 - ;;; Commentary: ;; Adapter for https://marketplace.visualstudio.com/items?itemName=Unity.unity-debug @@ -31,24 +27,24 @@ (require 'dap-utils) (defcustom dap-unity-debug-path (expand-file-name "vscode/Unity.unity-debug" - dap-utils-extension-path) + dap-utils-extension-path) "The path to unity-debug vscode extension." :group 'dap-unity :type 'string) (defcustom dap-unity-debug-program (expand-file-name "extension/bin/UnityDebug.exe" - dap-unity-debug-path) + dap-unity-debug-path) "The path to the unity debugger." :group 'dap-unity :type 'string) (dap-utils-vscode-setup-function "dap-unity" "Unity" "unity-debug" dap-unity-debug-path - nil - (lambda () ;; After adapter is downloaded, flag the debugger as executable - (unless (eq system-type 'windows-nt) - (shell-command - (concat "chmod u+x " dap-unity-debug-program))))) + nil + (lambda () ;; After adapter is downloaded, flag the debugger as executable + (unless (eq system-type 'windows-nt) + (shell-command + (concat "chmod u+x " dap-unity-debug-program))))) (defun dap-unity--populate-start-file-args (conf) "Populate CONF with the required arguments." diff --git a/dap-utils.el b/dap-utils.el index 19bb4bc3..4e6b8cf7 100644 --- a/dap-utils.el +++ b/dap-utils.el @@ -18,10 +18,6 @@ ;; 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/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1")) -;; Version: 0.2 - ;;; Commentary: ;; Dap-mode utils