From 06594a5d3de4634427d0db93e2e3c52988e16531 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 6 Apr 2024 02:03:11 -0700 Subject: [PATCH] fix: Byte-compile warnings (#786) --- dap-chrome.el | 4 - dap-dlv-go.el | 294 ++++++++++++++++++++++++----------------------- dap-docker.el | 39 +++---- dap-edge.el | 6 +- dap-elixir.el | 4 - dap-erlang.el | 11 +- dap-firefox.el | 4 - dap-gdb-lldb.el | 8 +- dap-gdscript.el | 31 ++--- dap-go.el | 165 +++++++++++++------------- dap-hydra.el | 7 +- dap-js.el | 4 - dap-kotlin.el | 60 ++++++---- dap-launch.el | 108 ++++++++--------- dap-lldb.el | 14 +-- dap-magik.el | 24 ++-- dap-mode.el | 29 ++--- dap-netcore.el | 160 +++++++++++++------------- dap-overlays.el | 2 +- dap-ui.el | 99 ++++++++-------- dap-variables.el | 4 +- 21 files changed, 529 insertions(+), 548 deletions(-) diff --git a/dap-chrome.el b/dap-chrome.el index e1be90de..0e99d8e0 100644 --- a/dap-chrome.el +++ b/dap-chrome.el @@ -18,10 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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/chromeide/vscode-chrome diff --git a/dap-dlv-go.el b/dap-dlv-go.el index 8fc384f7..8e0bb9a1 100644 --- a/dap-dlv-go.el +++ b/dap-dlv-go.el @@ -29,15 +29,16 @@ (require 'dap-mode) (require 'dap-utils) +(require 'dap-ui) (require 'f) (require 'lsp-mode) (require 'dash) (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) @@ -47,69 +48,74 @@ :group 'dap-dlv-go :type 'string) +(defvar vterm-shell) +(defvar vterm-kill-buffer-on-exit) +(declare-function vterm-mode "ext:vterm.el") + (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")))))) + (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")))))) (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 :type "go") - (dap--put-if-absent :name "Go Dlv Debug"))) + (dap--put-if-absent :dlvToolPath dap-dlv-go-delve-path) + + (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." @@ -118,59 +124,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." @@ -182,80 +188,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-docker.el b/dap-docker.el index 7d013a04..a8a51306 100644 --- a/dap-docker.el +++ b/dap-docker.el @@ -15,12 +15,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; Author: Andrei Mochalov -;; Keywords: languages, debug, docker -;; URL: https://github.com/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "26.1") (dash "2.18.0") (lsp-mode "6.0") (f "0.20.0") (s "1.12.0") (ht "2.3") (lsp-docker "1.0.0") (yaml "0.2.0")) -;; Version: 0.2 - ;;; Commentary: ;; Debug Adapter Protocol client support for Emacs and docker-wrapped servers. @@ -37,25 +31,26 @@ (defvar dap-docker-supported-server-types-subtypes (ht ('docker (list 'container 'image))) - "A list of all supported server types and subtypes, currently only docker is supported") + "A list of all supported server types and subtypes, currently only docker +is supported.") (defun dap-docker--is-enabled? (config) "Check whether debugging is enabled" (-when-let* ((server-info (gethash 'debug config)) (server-enabled (gethash 'enabled server-info))) - (not (equal server-enabled :false)))) + (not (equal server-enabled :false)))) (defun dap-docker--get-debug-provider-name (config) "Get the debug provider name also checking whether debugging is enabled" (-if-let* ((server-info (gethash 'debug config)) - (server-enabled (dap-docker--is-enabled? config))) + (server-enabled (dap-docker--is-enabled? config))) (gethash 'provider server-info) (user-error "Either debug is not enabled or the config is invalid!"))) (defun dap-docker--get-debug-template-name (config) "Get the debug template name also checking whether debugging is enabled" (-if-let* ((server-info (gethash 'debug config)) - (server-enabled (dap-docker--is-enabled? config))) + (server-enabled (dap-docker--is-enabled? config))) (gethash 'template server-info) (user-error "Either debug is not enabled or the config is invalid!"))) @@ -105,7 +100,8 @@ (gethash 'launch_command server-info))) (defun dap-docker--check-server-type-subtype (supported-server-types-subtypes server-type-subtype) - "Verify that the combination of server (type . subtype) is supported by the current implementation" + "Verify that the combination of server (type . subtype) is supported by the +current implementation" (if (not server-type-subtype) (user-error "No server type and subtype specified!")) (if (ht-find (lambda (type subtypes) @@ -124,7 +120,8 @@ path-mappings)) (defun dap-docker--verify-path-mappings-against-container (path-mappings container-name) - "Verify that specified path mappings are all included in container's path mappings" + "Verify that specified path mappings are all included in container's +path mappings." (--all? (let ((source (car it)) (destination (cdr it))) (-any? (lambda (mapping) @@ -141,9 +138,9 @@ "'{{json .Mounts}}'" (s-split " " (format "%s container inspect -f '{{.Mounts}}' %s" lsp-docker-command container-name))))) (-let (((exit-code . raw-output) (with-temp-buffer - (cons - (apply #'call-process inspection-command-program nil (current-buffer) nil inspection-command-arguments) - (buffer-string))))) + (cons + (apply #'call-process inspection-command-program nil (current-buffer) nil inspection-command-arguments) + (buffer-string))))) (if (equal exit-code 0) (let* ((output (s-chop-prefix "'" (s-chop-suffix "'" (s-chomp raw-output)))) (raw-mappings (append (json-parse-string output) nil)) ; using append to convert a vector to a list @@ -155,7 +152,8 @@ (defconst dap-docker-container-start-string "docker start -i &name&") (defun dap-docker--prepare-image-start-path (image-name path-mappings entrypoint) - "Get a command (splitted by spaces in a list form) for launching a server in a docker image" + "Get a command (splitted by spaces in a list form) for launching a server in +a docker image." (let* ((command (copy-sequence dap-docker-image-start-string)) (mappings-list (--map (s-join " " (list "-v" (s-join ":" (list (car it) (cdr it))))) path-mappings)) (mappings (s-join " " mappings-list))) @@ -165,13 +163,14 @@ (s-replace "&entrypoint&" entrypoint it)))) (defun dap-docker--prepare-container-start-path (container-name _ _) - "Get a command (splitted by spaces in a list form) for launching a server in a docker container" + "Get a command (splitted by spaces in a list form) for launching a server in +a docker container." (let ((command (copy-sequence dap-docker-container-start-string))) (--> command (s-replace "&name&" container-name it)))) (defun dap-docker--get-dockerized-debug-provider-name (debug-provider-name project-root) - "Create a new debug provider name using the original one and the project root" + "Create a new debug provider name using the original one and the project root." (s-join "-" (list (->> project-root @@ -212,8 +211,8 @@ "Make a particular debug provider docker-aware in a project folder" (-if-let* ((original-debug-provider (gethash debug-provider-name dap--debug-providers))) (dap-register-debug-provider (dap-docker--get-dockerized-debug-provider-name debug-provider-name project-root) - `(lambda (conf) - (funcall #'dap-docker--dockerize-start-file-args (funcall (quote ,original-debug-provider) conf) ,project-config ,project-root))))) + `(lambda (conf) + (funcall #'dap-docker--dockerize-start-file-args (funcall (quote ,original-debug-provider) conf) ,project-config ,project-root))))) (defun dap-docker--dockerize-debug-template (debug-template-name project-config project-root) "Make a particular debug template docker-aware in a project folder" diff --git a/dap-edge.el b/dap-edge.el index c5c27451..b2cc45a6 100644 --- a/dap-edge.el +++ b/dap-edge.el @@ -18,17 +18,13 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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-edge-debug-path (expand-file-name "vscode/msjsdiag.debugger-for-edge" - dap-utils-extension-path) + dap-utils-extension-path) "The path to edge vscode extension." :group 'dap-edge :type 'string) diff --git a/dap-elixir.el b/dap-elixir.el index 2066b2d3..3de01226 100644 --- a/dap-elixir.el +++ b/dap-elixir.el @@ -18,10 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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/elixir-lsp/elixir-ls diff --git a/dap-erlang.el b/dap-erlang.el index 35075c8e..7244726b 100644 --- a/dap-erlang.el +++ b/dap-erlang.el @@ -18,10 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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/erlang-ls/erlang_ls ;; Created by Roberto Aloi (@robertoaloi) @@ -33,10 +29,9 @@ (defun dap-erlang--populate-start-file-args (conf) "Populate CONF with the required arguments." (-> conf - (plist-put :dap-server-path '("els_dap")) - (plist-put :projectDir (lsp-find-session-folder (lsp-session) (buffer-file-name))) - (plist-put :cwd (lsp-find-session-folder (lsp-session) (buffer-file-name))) - )) + (plist-put :dap-server-path '("els_dap")) + (plist-put :projectDir (lsp-find-session-folder (lsp-session) (buffer-file-name))) + (plist-put :cwd (lsp-find-session-folder (lsp-session) (buffer-file-name))))) (dap-register-debug-provider "erlang" 'dap-erlang--populate-start-file-args) (provide 'dap-erlang) diff --git a/dap-firefox.el b/dap-firefox.el index c52b4bbf..f4690882 100644 --- a/dap-firefox.el +++ b/dap-firefox.el @@ -18,10 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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/firefoxide/vscode-firefox diff --git a/dap-gdb-lldb.el b/dap-gdb-lldb.el index 84527f19..e0d41984 100644 --- a/dap-gdb-lldb.el +++ b/dap-gdb-lldb.el @@ -72,7 +72,7 @@ With prefix, FORCED to redownload the extension." ;; This may become unnecessary once https://github.com/WebFreak001/code-debug/issues/344 is resolved. (dap--put-if-absent :valuesFormatting "prettyPrinters"))) - + (dap-register-debug-provider "gdb" 'dap-gdb-lldb--populate-gdb) (dap-register-debug-template "GDB Run Configuration" @@ -96,7 +96,7 @@ With prefix, FORCED to redownload the extension." ;; This may become unnecessary once https://github.com/WebFreak001/code-debug/issues/344 is resolved. (dap--put-if-absent :valuesFormatting "prettyPrinters"))) - + (dap-register-debug-provider "gdbserver" 'dap-gdb-lldb--populate-gdbserver) (dap-register-debug-template "GDBServer Connect Configuration" @@ -110,7 +110,7 @@ With prefix, FORCED to redownload the extension." :env nil :showDevDebugOutput :json-false :printCalls :json-false)) - + (defcustom dap-gdb-lldb-path-lldb `("node" ,(expand-file-name (f-join dap-gdb-lldb-path "extension/out/src/lldb.js"))) "The path to the LLDB debugger." @@ -128,7 +128,7 @@ With prefix, FORCED to redownload the extension." ;; This may become unnecessary once https://github.com/WebFreak001/code-debug/issues/344 is resolved. (dap--put-if-absent :valuesFormatting "prettyPrinters"))) - + (dap-register-debug-provider "lldb-mi" 'dap-gdb-lldb--populate-lldb) (dap-register-debug-template "LLDB Run Configuration" diff --git a/dap-gdscript.el b/dap-gdscript.el index 1206e685..ad00488a 100644 --- a/dap-gdscript.el +++ b/dap-gdscript.el @@ -18,17 +18,11 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; URL: https://github.com/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) -;; Version: 0.1 - ;;; Code: (require 'dap-mode) (require 'dap-utils) - - (defcustom dap-gdscript-debug-port 6006 "The port to the gdscript/godot4 debugger." :group 'dap-gdscript @@ -39,26 +33,25 @@ :group 'dap-gdscript :type 'string) - (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 d20e9162..16b2defd 100644 --- a/dap-go.el +++ b/dap-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 . -;; 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/golang/vscode-go @@ -37,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) @@ -60,97 +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")))) - )) - + (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")))))) (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-hydra.el b/dap-hydra.el index 584aaf56..357198a5 100644 --- a/dap-hydra.el +++ b/dap-hydra.el @@ -1,4 +1,4 @@ -;;; hydra-dap.el --- dap-mode integration with hydra -*- lexical-binding: t; -*- +;;; hydra-dap.el --- dap-mode integration with hydra -*- lexical-binding: t; -*- ;; Copyright (C) 2018 Ivan Yonchovski @@ -18,11 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; URL: https://github.com/emacs-lsp/dap-mode -;; Package-Requires: ((emacs "25.1") (hydra "0.14.0")) -;; Version: 0.2 -;; Hydra - ;;; Commentary: ;; Defines hydra for `dap-mode' operations diff --git a/dap-js.el b/dap-js.el index 4c22f5c1..33b515d1 100644 --- a/dap-js.el +++ b/dap-js.el @@ -18,10 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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) diff --git a/dap-kotlin.el b/dap-kotlin.el index 6617bc46..32f08c70 100644 --- a/dap-kotlin.el +++ b/dap-kotlin.el @@ -1,6 +1,25 @@ +;;; dap-kotlin.el --- Debug Adapter Protocol mode for Kotlin -*- lexical-binding: t; -*- + +;; Copyright (C) 2019-2024 emacs-lsp maintainers + +;; 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 . + ;; Commentary: ;; Adapter for https://github.com/fwcd/kotlin-debug-adapter +;;; Code: + (require 'lsp-kotlin) (require 'dap-mode) @@ -18,29 +37,29 @@ ;; we require mainClass to be filled in in the launch configuration. ;; dap-kotlin does currently not support a fallback if not defined (-> conf - (dap--put-if-absent :request "launch") - (dap--put-if-absent :name "Kotlin Launch") - (dap--put-if-absent :projectRoot (lsp-workspace-root)) - (dap--put-if-absent :enableJsonLogging (lsp-json-bool dap-kotlin-enable-log)) - (dap--put-if-absent :jsonLogFile dap-kotlin-log-path))) + (dap--put-if-absent :request "launch") + (dap--put-if-absent :name "Kotlin Launch") + (dap--put-if-absent :projectRoot (lsp-workspace-root)) + (dap--put-if-absent :enableJsonLogging (lsp-json-bool dap-kotlin-enable-log)) + (dap--put-if-absent :jsonLogFile dap-kotlin-log-path))) (defun dap-kotlin-populate-attach-args (conf) (-> conf - (dap--put-if-absent :request "attach") - (dap--put-if-absent :name "Kotlin Attach") - (dap--put-if-absent :projectRoot (lsp-workspace-root)) - (dap--put-if-absent :hostName "localhost") - (dap--put-if-absent :port 5005) - (dap--put-if-absent :timeout 2000) - (dap--put-if-absent :enableJsonLogging (lsp-json-bool dap-kotlin-enable-log)) - (dap--put-if-absent :jsonLogFile dap-kotlin-log-path))) + (dap--put-if-absent :request "attach") + (dap--put-if-absent :name "Kotlin Attach") + (dap--put-if-absent :projectRoot (lsp-workspace-root)) + (dap--put-if-absent :hostName "localhost") + (dap--put-if-absent :port 5005) + (dap--put-if-absent :timeout 2000) + (dap--put-if-absent :enableJsonLogging (lsp-json-bool dap-kotlin-enable-log)) + (dap--put-if-absent :jsonLogFile dap-kotlin-log-path))) (defun dap-kotlin-populate-default-args (conf) (setq conf (pcase (plist-get conf :request) - ("launch" (dap-kotlin-populate-launch-args conf)) - ("attach" (dap-kotlin-populate-attach-args conf)) - (_ (error "Unsupported dap-request")))) - + ("launch" (dap-kotlin-populate-launch-args conf)) + ("attach" (dap-kotlin-populate-attach-args conf)) + (_ (error "Unsupported dap-request")))) + (-> conf (dap--put-if-absent :type "kotlin") (plist-put :dap-server-path (list lsp-kotlin-debug-adapter-path)))) @@ -48,8 +67,9 @@ (dap-register-debug-provider "kotlin" #'dap-kotlin-populate-default-args) (dap-register-debug-template "Kotlin Attach" - (list :type "kotlin" - :request "attach" - :noDebug nil)) + (list :type "kotlin" + :request "attach" + :noDebug nil)) (provide 'dap-kotlin) +;;; dap-kotlin.el ends here diff --git a/dap-launch.el b/dap-launch.el index 6d5f352c..cee99e7e 100644 --- a/dap-launch.el +++ b/dap-launch.el @@ -31,48 +31,48 @@ "Return the path to current project's launch.json file. Yields nil if it cannot be found or there is no project." (when-let ((root (lsp-workspace-root))) - (require 'dap-variables) - (dap-variables-find-vscode-config "launch.json" root))) + (require 'dap-variables) + (dap-variables-find-vscode-config "launch.json" root))) (defun dap-launch-get-launch-json () "Parse the project's launch.json as json data and return the result." (require 'dap-utils) (when-let ((launch-json (dap-launch-find-launch-json)) - (json-object-type 'plist) - ;; Use 'vector instead of 'list. With 'list for array type, - ;; json-encode-list interpreted a list with one plist element as - ;; an alist. Using 'list, it turned the following value of - ;; pathMappings: - ;; - ;; "pathMappings": [ - ;; { - ;; "localRoot": "${workspaceFolder}", - ;; "remoteRoot": "." - ;; } - ;; ] - ;; - ;; into: - ;; - ;; ((:localRoot "${workspaceFolder}" :remoteRoot ".")) - ;; - ;; and then into: - ;; - ;; "pathMappings": { - ;; "localRoot": [ - ;; "${workspaceFolder}", - ;; "remoteRoot", - ;; "." - ;; ] - ;; } - (json-array-type 'vector)) - (with-temp-buffer - ;; NOTE: insert-file-contents does not move point - (insert-file-contents launch-json) - (dap-utils-sanitize-json) - ;; dap-launch-remove-comments does move point - (goto-char (point-min)) - - (json-read)))) + (json-object-type 'plist) + ;; Use 'vector instead of 'list. With 'list for array type, + ;; json-encode-list interpreted a list with one plist element as + ;; an alist. Using 'list, it turned the following value of + ;; pathMappings: + ;; + ;; "pathMappings": [ + ;; { + ;; "localRoot": "${workspaceFolder}", + ;; "remoteRoot": "." + ;; } + ;; ] + ;; + ;; into: + ;; + ;; ((:localRoot "${workspaceFolder}" :remoteRoot ".")) + ;; + ;; and then into: + ;; + ;; "pathMappings": { + ;; "localRoot": [ + ;; "${workspaceFolder}", + ;; "remoteRoot", + ;; "." + ;; ] + ;; } + (json-array-type 'vector)) + (with-temp-buffer + ;; NOTE: insert-file-contents does not move point + (insert-file-contents launch-json) + (dap-utils-sanitize-json) + ;; dap-launch-remove-comments does move point + (goto-char (point-min)) + + (json-read)))) (defun dap-launch-configuration-get-name (conf) "Return the name of launch configuration CONF." @@ -87,36 +87,36 @@ Extract the name from the :name property." "Transform environment config into dap-mode format. This handles a single configuration plist." (if (not (plist-get conf :environment)) - ;; No environment specified, just return the old configuration - conf - ;; Standard format for the "environment" key is - ;; {"name": "foo", "value": "bar"}, - ;; which results in a (:name "foo" :value "bar) plist. - ;; We need to transform this into a ("foo" . "bar") cons cell. - (let ((environ-spec (mapcar - (lambda (env-plist) - (cons (plist-get env-plist :name) - (plist-get env-plist :value))) - (plist-get conf :environment)))) - (plist-put conf :environment-variables environ-spec)))) + ;; No environment specified, just return the old configuration + conf + ;; Standard format for the "environment" key is + ;; {"name": "foo", "value": "bar"}, + ;; which results in a (:name "foo" :value "bar) plist. + ;; We need to transform this into a ("foo" . "bar") cons cell. + (let ((environ-spec (mapcar + (lambda (env-plist) + (cons (plist-get env-plist :name) + (plist-get env-plist :value))) + (plist-get conf :environment)))) + (plist-put conf :environment-variables environ-spec)))) (defun dap--launch-extract-environments (conflist) - "Transform environment config into dap-mode format. + "Transform environment config into dap-mode format. This is intended to be run on a list of configurations." - (mapcar #'dap--launch-extract-environment conflist)) + (mapcar #'dap--launch-extract-environment conflist)) (defun dap-launch-parse-launch-json (json) "Return a list of all launch configurations in JSON. JSON must have been acquired with `dap-launch--get-launch-json'." (mapcar #'dap-launch-configuration-prepend-name - (dap--launch-extract-environments - (or (plist-get json :configurations) (list json))))) + (dap--launch-extract-environments + (or (plist-get json :configurations) (list json))))) (defun dap-launch-find-parse-launch-json () "Return a list of all launch configurations for the current project. Usable as a dap-launch-configuration-providers backend." (when-let ((launch-json (dap-launch-get-launch-json))) - (dap-launch-parse-launch-json launch-json))) + (dap-launch-parse-launch-json launch-json))) (provide 'dap-launch) ;;; dap-launch.el ends here diff --git a/dap-lldb.el b/dap-lldb.el index f3745300..200d71fb 100644 --- a/dap-lldb.el +++ b/dap-lldb.el @@ -18,10 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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/llvm-mirror/lldb/tree/master/tools/lldb-vscode @@ -54,11 +50,11 @@ '(progn (dap-register-debug-provider "lldb-vscode" 'dap-lldb--populate-start-file-args) (dap-register-debug-template "LLDB (VS Code) :: Run Configuration" - (list :type "lldb-vscode" - :cwd nil - :request "launch" - :program nil - :name "LLDB::Run")))) + (list :type "lldb-vscode" + :cwd nil + :request "launch" + :program nil + :name "LLDB::Run")))) (provide 'dap-lldb) ;;; dap-lldb.el ends here diff --git a/dap-magik.el b/dap-magik.el index 97a1a1f4..d3cefb82 100644 --- a/dap-magik.el +++ b/dap-magik.el @@ -55,7 +55,7 @@ :package-version '(dap . "0.9.1")) (defcustom dap-magik-java-path (cond ((eq system-type 'windows-nt) "$JAVA_HOME/bin/java") - (t "java")) + (t "java")) "Path of the java executable." :type 'string :group 'dap-magik @@ -82,26 +82,26 @@ (defun dap-magik-download-da () "Download the Magik Debug Adapter." (unless (file-exists-p (f-join dap-utils-extension-path "magik")) - (make-directory (f-join dap-utils-extension-path "magik") t)) + (make-directory (f-join dap-utils-extension-path "magik") t)) (unless (file-exists-p dap-magik-path) - (url-copy-file dap-magik-download-url dap-magik-path 'overwrite) - (message "%s: Downloading done!" "dap-magik"))) + (url-copy-file dap-magik-download-url dap-magik-path 'overwrite) + (message "%s: Downloading done!" "dap-magik"))) (dap-magik-download-da) (defun dap-magik--populate-attach-args (conf) "Populate CONF with the required arguments." (-> conf - (dap--put-if-absent :dap-server-path (list dap-magik-java-path "-jar" dap-magik-path "--debug")) - (dap--put-if-absent :type "magik") - (dap--put-if-absent :request "attach") - (dap--put-if-absent :connect (list :host dap-magik-attach-host - :port dap-magik-attach-port)))) + (dap--put-if-absent :dap-server-path (list dap-magik-java-path "-jar" dap-magik-path "--debug")) + (dap--put-if-absent :type "magik") + (dap--put-if-absent :request "attach") + (dap--put-if-absent :connect (list :host dap-magik-attach-host + :port dap-magik-attach-port)))) (dap-register-debug-template "Magik Attach Configuration" - (list :type "magik" - :request "attach" - :name "Magik::Attach")) + (list :type "magik" + :request "attach" + :name "Magik::Attach")) (dap-register-debug-provider "magik" #'dap-magik--populate-attach-args) diff --git a/dap-mode.el b/dap-mode.el index 05eba256..7db4083e 100644 --- a/dap-mode.el +++ b/dap-mode.el @@ -1,6 +1,6 @@ ;;; dap-mode.el --- Debug Adapter Protocol mode -*- lexical-binding: t; -*- -;; Copyright (C) 2019 Ivan Yonchovski +;; Copyright (C) 2019-2024 emacs-lsp maintainers ;; 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 @@ -864,7 +864,7 @@ will be reversed." ;; extract the list of buffers featuring a breakpoint from their first breakpoint marker ;; (as stored in the LSP metadata) (--map (marker-buffer (plist-get (car it) :marker)) - (ht-values (dap--get-breakpoints)))) + (ht-values (dap--get-breakpoints)))) (defun dap--refresh-breakpoints () "Refresh breakpoints for DEBUG-SESSION." @@ -894,14 +894,16 @@ will be reversed." (funcall cleanup-fn debug-session))) (defun dap--output-buffer-format-with-category (category output) - "Formats a string suitable for printing to the output buffer using CATEGORY and OUTPUT." + "Formats a string suitable for printing to the output buffer using +CATEGORY and OUTPUT." (let ((message (format "%s: %s" category output))) (if (string= (substring message -1) "\n") message (concat message "\n")))) (defun dap--output-buffer-format (output-body) - "Formats a string suitable for printing to the output buffer using an OUTPUT-BODY." + "Formats a string suitable for printing to the output buffer using +an OUTPUT-BODY." (if dap-label-output-buffer-category (dap--output-buffer-format-with-category (gethash "category" output-body) (gethash "output" output-body)) @@ -1268,7 +1270,7 @@ ADAPTER-ID the id of the adapter." debug-session)) (defun dap--send-configuration-done (debug-session) - "Send 'configurationDone' message for DEBUG-SESSION." + "Send `configurationDone' message for DEBUG-SESSION." (dap--send-message (dap--make-request "configurationDone") (dap--resp-handler (lambda (_) @@ -1398,7 +1400,8 @@ RESULT to use for the callback." (dap-eval (buffer-substring-no-properties start end))) (defun dap-switch-stack-frame () - "Switch stackframe by selecting another stackframe stackframes from current thread." + "Switch stackframe by selecting another stackframe stackframes from +current thread." (interactive) (when (not (dap--cur-session)) (error "There is no active session")) @@ -1707,18 +1710,18 @@ If ORIGIN is t, return the original configuration without prepopulation" dap-debug-template-configurations) (defconst dap-launch-configuration-providers - '(dap-launch-find-parse-launch-json - dap-debug-template-configurations-provider) + '( dap-launch-find-parse-launch-json + dap-debug-template-configurations-provider) "List of functions that can contribute launch configurations to dap-debug. When the user invokes dap-debug, all of the functions in this list are called and their results (which must be lists) are -concatenated. The user can then choose one of them from the +concatenated. The user can then choose one of them from the resulting list.") (defconst dap-tasks-configuration-providers '(dap-tasks-find-parse-tasks-json) "List of functions that can contribute task configurations to dap-debug. -When a launch configuration specifies a 'preLaunchTask', it can pull from +When a launch configuration specifies a `preLaunchTask', it can pull from the results of these functions.") (defun dap-start-debugging (conf) @@ -1899,9 +1902,9 @@ be used to compile the project, spin up docker, ...." (defun dap-debug-edit-template (&optional debug-args) "Edit registered template DEBUG-ARGS. -When being invoked with prefix argument, poping up the prepopulated version of the template. -Otherwise, return its original version. After registration, the new template can be used -normally with `dap-debug'" +When being invoked with prefix argument, poping up the prepopulated version of +the template. Otherwise, return its original version. After registration, +the new template can be used normally with `dap-debug'" (interactive) (unless debug-args (setq debug-args (dap--select-template (not current-prefix-arg)))) diff --git a/dap-netcore.el b/dap-netcore.el index 18ac4721..7f1512fa 100644 --- a/dap-netcore.el +++ b/dap-netcore.el @@ -18,10 +18,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; 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.2 - ;;; Commentary: ;; Adapter for https://github.com/Samsung/netcoredbg . ;;; Code: @@ -38,8 +34,9 @@ (defcustom dap-netcore-download-url nil "Netcoredbg download url. -See asset links here https://github.com/Samsung/netcoredbg/releases/ and select the correct one for your OS. -Will be set automatically in Emacs 27.1 or newer with libxml2 support." +See asset links here https://github.com/Samsung/netcoredbg/releases/ and select +the correct one for your OS. Will be set automatically in Emacs 27.1 or newer +with libxml2 support." :group 'dap-netcore :risky t :type 'string) @@ -48,47 +45,48 @@ Will be set automatically in Emacs 27.1 or newer 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 + (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) + (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'." + "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)) + (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 (_) + (lambda (_) (setq dap-netcore-download-url - (concat - "https://github.com" - (dom-attr + (concat + "https://github.com" + (dom-attr (dom-search (if (libxml-available-p) - (libxml-parse-html-region (point-min) (point-max)) + (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" + (`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")) + (`darwin ".*osx.*\\.tar\\.gz") + (`windows-nt ".*win64.*\\.zip")) (or (dom-attr node 'href) "")))) 'href))) (lsp-download-install @@ -98,12 +96,12 @@ Will be set automatically in Emacs 27.1 or newer with libxml2 support." (user-error "Error during netcoredbg downloading: %s" error)) :url dap-netcore-download-url :store-path temp-file))) - (if dap-netcore-download-url + (if dap-netcore-download-url (lsp-download-install (lambda (&rest _) - (shell-command unzip-script)) + (shell-command unzip-script)) (lambda (error &rest _) - (user-error "Error during netcoredbg downloading: %s" error)) + (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"))))) @@ -111,20 +109,20 @@ Will be set automatically in Emacs 27.1 or newer with libxml2 support." (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. @@ -140,61 +138,61 @@ 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) + 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)))) + (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 + ("launch" + (dap--put-if-absent + conf + :program + (let ((project-dir (f-full (or (dap-netcore--locate-dominating-file-wildcard - default-directory "*.*proj") + 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")))))) + (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" + (list :type "coreclr" + :request "launch" + :mode "launch" + :name "NetCoreDbg::Launch" :dap-compilation "dotnet build")) (provide 'dap-netcore) diff --git a/dap-overlays.el b/dap-overlays.el index 920e8c65..593334a5 100644 --- a/dap-overlays.el +++ b/dap-overlays.el @@ -91,7 +91,7 @@ Never throws errors, and can be used in an overlay's modification-hooks." "Place an overlay between L and R and return it. TYPE is a symbol put on the overlay's category property. It is used to easily remove all overlays from a region with: - (remove-overlays start end 'category TYPE) + (remove-overlays start end `category TYPE) PROPS is a plist of properties and values to add to the overlay." (let ((o (make-overlay l (or r l) (current-buffer)))) (overlay-put o 'category type) diff --git a/dap-ui.el b/dap-ui.el index 9dfd1c07..b48615d1 100644 --- a/dap-ui.el +++ b/dap-ui.el @@ -233,7 +233,8 @@ VISUALS and MSG will be used for the overlay." (when (integer-or-marker-p point) (save-excursion (goto-char point) - (dap-ui--make-overlay (point-at-bol) (point-at-eol) visuals nil buf)))))) + (dap-ui--make-overlay (line-beginning-position) (line-end-position) + visuals nil buf)))))) (defvar-local dap-ui--breakpoint-overlays nil) @@ -436,15 +437,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." @@ -634,32 +635,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) @@ -829,13 +830,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. @@ -1021,7 +1022,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) @@ -1117,34 +1118,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) @@ -1423,7 +1424,7 @@ TEXT is the current input." (dap--make-request "completions" (list :frameId frame-id :text text - :column (- (length text) (- (point-at-eol) (point))))) + :column (- (length text) (- (line-end-position) (point))))) (dap--resp-handler (lambda (result) (-if-let (targets (-some->> result (gethash "body") (gethash "targets"))) diff --git a/dap-variables.el b/dap-variables.el index e2e5fca4..982fe65b 100644 --- a/dap-variables.el +++ b/dap-variables.el @@ -106,10 +106,10 @@ and not from the current buffer." The return value of a VAR-CB invocation is ignored. Special case: if TREE (or one of its subtrees) is cons whose -`cdr' does not satisfy `listp' (e.g. '(\"foo\" . \"bar\")), its +`cdr' does not satisfy `listp' (e.g. `(\"foo\" . \"bar\")), its `car' is left as is and its `cdr' is expanded recursively. Note that a dotted pair whose `cdr' is a list cannot be told from a -list. So, '(4 5) and '(4 . (5)) are `equal'. As such, you should +list. So, `(4 5) and `(4 . (5)) are `equal'. As such, you should use plists when parsing from JSON. TREE can be a ...: