[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dape ba63e50434 106/123: Batteries included
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dape ba63e50434 106/123: Batteries included |
Date: |
Tue, 5 Dec 2023 03:58:05 -0500 (EST) |
branch: externals/dape
commit ba63e50434bc7687f3eac638d31d92718076ed2f
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Daniel Pettersson <daniel@dpettersson.net>
Batteries included
---
README.org | 130 +++++++---------------------------------
dape.el | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 214 insertions(+), 115 deletions(-)
diff --git a/README.org b/README.org
index 2c3eca8971..3afe6f6227 100644
--- a/README.org
+++ b/README.org
@@ -67,141 +67,51 @@ Dape takes a slightly different approach to configuration.
+ Tries to simplify configuration, by having just a plist.
+ Dape tries to improve config ergonomics in ~dape~ completing-read by using
options to change/add plist entries in an already existing config, example:
~adapter-config :program "/home/user/b.out" compile "gcc -g -o b.out main.c"~.
+ No magic, no special variables. Instead, functions and variables are
resolved before starting a new session.
-+ No batteries included. Many, suffer from a significant drawback: they're
tightly coupled with the vscode extension they're bundled with. This tight
coupling results in launch/attach requests being specific to each adapter,
devoid of reasonable defaults as they are stored within the extension itself,
leading to an ever-changing and unstable API. Consequently, attempting to
include default configurations for each adapter seems like a losing proposition.
+ Tries to be envision to how debug adapter configuration would be implemented
in emacs if vscode never existed.
* Supported debug adapters
In theory all debug adapters should be compatible with =Dape=.
-** Javascript - vscode-js-debug
-To install ~vscode-js-debug~ pull down the
[[https://github.com/microsoft/vscode-js-debug][repo]].
-#+begin_src sh
- npm install
- npx gulp dapDebugServer
-#+end_src
-
-Example launch configuration for ~node~.
-#+begin_src emacs-lisp
- (add-to-list 'dape-configs
- `(vscode-js-node
- modes (js-mode js-ts-mode)
- host "localhost"
- port 8123
- command "node"
- command-cwd "path/to/vscode-js-debug/dist/"
- command-args ("src/dapDebugServer.js" "8123")
- :type "pwa-node"
- :request "launch"
- :cwd dape-cwd-fn
- :program dape-find-file-buffer-default
- :outputCapture "console"
- :sourceMapRenames t
- :pauseForSourceMap nil
- :enableContentValidation t
- :autoAttachChildProcesses t
- :console "internalConsole"
- :killBehavior "forceful"))
-#+end_src
+** Javascript - vscode-js-*
+1. Install `node`
+2. Visit https://github.com/microsoft/vscode-js-debug/releases/ and download
the asset `js-debug-dap-<version>.tar.gz`
+3. Unpack `mkdir -p ~/.emacs.d/debug-adapters && tar -xvzf
js-debug-dap-<version>.tar.gz -C ~/.emacs.d/debug-adapters`
For more information see
[[https://github.com/microsoft/vscode-js-debug/blob/main/OPTIONS.md][OPTIONS.md]].
-** Go - delve
+** Go - dlv
See
[[https://github.com/go-delve/delve/tree/master/Documentation/installation][delve
installation]].
-
-#+begin_src emacs-lisp
- (add-to-list 'dape-configs
- `(delve
- modes (go-mode go-ts-mode)
- command "dlv"
- command-args ("dap" "--listen" "127.0.0.1:55878")
- command-cwd dape-cwd-fn
- host "127.0.0.1"
- port 55878
- :type "debug"
- :request "launch"
- :cwd dape-cwd-fn
- :program dape-cwd-fn))
-#+end_src
-
For more information see
[[https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md][documentation]].
-** C, C++ and Rust
-Download latest [[https://github.com/vadimcn/codelldb/releases][release]] and
unpack ~vsix~ file with your favorite unzipper.
-
-#+begin_src emacs-lisp
- (add-to-list 'dape-configs
- '(codelldb
- modes (c-mode c-ts-mode
- c++-mode c++-ts-mode
- ;; Uncomment the following if you use rust-mode
- ;; rust-mode rust-ts-mode
- )
- ;; Replace vadimcn.vscode-lldb with the vsix directory you
just extracted
- command "path/to/vadimcn.vscode-lldb/adapter/codelldb"
- host "localhost"
- port 5818
- command-args ("--port" "5818")
- :type "lldb"
- :request "launch"
- :cwd dape-cwd-fn
- :program dape-find-file))
-#+end_src
+** C, C++ and Rust - codelldb
+1. Download latest ~vsix~
[[https://github.com/vadimcn/codelldb/releases][release]] for your platform
`codelldb-<platform>-<os>.vsix`
+2. Unpack `mkdir -p ~/.emacs.d/debug-adapters && unzip
codelldb-<platform>-<os>.vsix -d ~/.emacs.d/debug-adapters/codelldb`
See [[https://github.com/vadimcn/codelldb/blob/v1.10.0/MANUAL.md][manual]] for
more information.
-** C and C++ - cppdbg
-Download latest
[[https://github.com/microsoft/vscode-cpptools/releases][release]] and unpack
~vsix~ file with your favorite unzipper.
-Then ~chmod +x debugAdapters/bin/OpenDebugAD7~.
+** C and C++ - cpptools
+Download latesnd unpack ~vsix~ file with your favorite unzipper.
-#+begin_src emacs-lisp
- ;; Replace ms-vscode.cpptools with the vsix directory you just extracted
- (setq dape-cppdbg-command
"path/to/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7")
- (add-to-list 'dape-configs
- `(cppdbg
- modes (c-mode c-ts-mode c++-mode c++-ts-mode)
- command-cwd ,(file-name-directory
- dape-cppdbg-command)
- command dape-cppdbg-command
- :type "cppdbg"
- :request "launch"
- :cwd dape-cwd-fn
- :program dape-find-file
- :MIMode ,(cond
- ((executable-find "gdb") "gdb")
- ((executable-find "lldb") "lldb"))))
-#+end_src
+1. Download latest ~vsix~
[[https://github.com/microsoft/vscode-cpptools/releases][release]] for your
platform `cpptools-<platform>-<os>.vsix`
+2. Unpack `mkdir -p ~/.emacs.d/debug-adapters && unzip
cpptools-<os>-<platform>.vsix -d ~/.emacs.d/debug-adapters/cpptools`
+3. Then `chmod +x
~/.emacs.d/debug-adapters/cpptools/extension/debugAdapters/bin/OpenDebugAD7`
+4. And `chmod +x
~/.emacs.d/debug-adapters/cpptools/extension/debugAdapters/lldb-mi/bin/lldb-mi`
See [[https://code.visualstudio.com/docs/cpp/launch-json-reference][options]].
** Python - debugpy
-Install debugpy with pip ~pip install debugpy~
-
-#+begin_src emacs-lisp
- (add-to-list 'dape-configs
- `(debugpy
- modes (python-ts-mode python-mode)
- command "python3"
- command-args ("-m" "debugpy.adapter")
- :type "executable"
- :request "launch"
- :cwd dape-cwd-fn
- :program dape-find-file-buffer-default))
-#+end_src
+Install debugpy with pip `pip install debugpy`
See
[[https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings][options]].
** Godot
Configure debug adapter port under "Editor" -> "Editor Settings" -> "Debug
Adapter".
-#+begin_src emacs-lisp
- (add-to-list 'dape-configs
- '(godot-launch
- modes (gdscript-mode)
- host "127.0.0.1"
- port 6006
- :type "server"
- :request "launch"))
-#+end_src
+** Dart - flutter
+See for installation https://docs.flutter.dev/get-started/install
+
+** C# - netcoredbg
+See https://github.com/Samsung/netcoredbg for installation
** Other untested adapters
If you find a working configuration for any other debug adapter please submit
a PR.
diff --git a/dape.el b/dape.el
index d7410899a7..de788ce64b 100644
--- a/dape.el
+++ b/dape.el
@@ -53,7 +53,150 @@
:prefix "dape-"
:group 'applications)
-(defcustom dape-configs nil
+(defcustom dape-adapter-dir
+ (file-name-as-directory (concat user-emacs-directory "debug-adapters"))
+ "Directory to store downloaded adapters in."
+ :type 'string)
+
+(defcustom dape-configs
+ `(,@(let ((codelldb
+ `(ensure dape-ensure-command
+ command ,(file-name-concat dape-adapter-dir
+ "codelldb"
+ "extension"
+ "adapter"
+ "codelldb")
+ port :autoport
+ fn dape-config-autoport
+ :type "lldb"
+ :request "launch"
+ :cwd dape-cwd-fn
+ :program dape-find-file
+ :args [])))
+ `((codelldb-cc
+ modes (c-mode c-ts-mode c++-mode c++-ts-mode)
+ command-args ("--port" :autoport)
+ ,@codelldb)
+ (codelldb-rust
+ modes (rust-mode rust-ts-mode)
+ command-args ("--port" :autoport
+ "--settings" "{\"sourceLanguages\":[\"rust\"]}")
+ ,@codelldb)))
+ (cpptools
+ modes (c-mode c-ts-mode c++-mode c++-ts-mode)
+ ensure dape-ensure-command
+ command ,(file-name-concat dape-adapter-dir
+ "cpptools"
+ "extension"
+ "debugAdapters"
+ "bin"
+ "OpenDebugAD7")
+ :type "cppdbg"
+ :request "launch"
+ :cwd dape-cwd-fn
+ :program dape-find-file
+ :MIMode ,(seq-find 'executable-find '("lldb" "gdb")))
+ (debugpy
+ modes (python-mode python-ts-mode)
+ ensure (lambda (config)
+ (let ((python
+ (dape--config-eval-value (plist-get config 'command))))
+ (unless (zerop
+ (call-process-shell-command
+ (format "%s -c \"import debugpy.adapter\"" python)))
+ (user-error "%s module debugpy is not installed" python))))
+ command "python3"
+ command-args ("-m" "debugpy.adapter")
+ :request "launch"
+ :type "executable"
+ :cwd dape-cwd-fn
+ :program dape-find-file-buffer-default
+ :justMyCode nil
+ :showReturnValue t)
+ (dlv
+ modes (go-mode go-ts-mode)
+ ensure dape-ensure-command
+ fn dape-config-autoport
+ command "dlv"
+ command-args ("dap" "--listen" "127.0.0.1::autoport")
+ command-cwd dape-cwd-fn
+ port :autoport
+ :request "launch"
+ :type "debug"
+ :cwd dape-cwd-fn
+ :program dape-cwd-fn)
+ (flutter
+ ensure dape-ensure-command
+ modes (dart-mode)
+ command "flutter"
+ command-args ("debug_adapter")
+ command-cwd dape-cwd-fn
+ :type "dart"
+ :cwd dape-cwd-fn
+ :program dape-find-file-buffer-default
+ :toolArgs ,(lambda () (vector "-d" (read-string "Device id: "))))
+ (godot
+ modes (gdscript-mode)
+ port 6006
+ :request "launch"
+ :type "server"
+ :cwd dape-cwd-fn)
+ ,@(let ((js-debug
+ `(modes (js-mode js-ts-mode)
+ ensure ,(lambda (config)
+ (dape-ensure-command config)
+ (let* ((command-cwd
+ (dape--config-eval-value (plist-get config
'command-cwd)))
+ (command
+ (file-name-concat command-cwd
+ (dape--config-eval-value
(car (plist-get config 'command-args))))))
+ (unless (file-exists-p command-cwd)
+ (user-error "Directory %s does not exist"
command-cwd))
+ (unless (file-exists-p command)
+ (user-error "Command %s does not exist"
command))))
+ command "node"
+ command-cwd ,(file-name-concat dape-adapter-dir
+ "js-debug")
+ command-args (,(file-name-concat "src" "dapDebugServer.js")
+ :autoport)
+ port :autoport
+ fn dape-config-autoport)))
+ `((js-debug-node
+ ,@js-debug
+ :type "pwa-node"
+ :cwd dape-cwd-fn
+ :program dape-find-file-buffer-default
+ :outputCapture "console"
+ :sourceMapRenames t
+ :pauseForSourceMap nil
+ :autoAttachChildProcesses t
+ :console "internalConsole"
+ :killBehavior "forceful")
+ (js-debug-chrome
+ ,@js-debug
+ :type "pwa-chrome"
+ :trace t
+ :url ,(lambda ()
+ (read-string "Url: "
+ "http://localhost:3000"))
+ :webRoot dape-cwd-fn
+ :outputCapture "console")))
+ (lldb-vscode
+ modes (c-mode c-ts-mode c++-mode c++-ts-mode rust-mode rust-ts-mode)
+ ensure dape-ensure-command
+ command "lldb-vscode"
+ :type "lldb-vscode"
+ :cwd dape-cwd-fn
+ :program dape-find-file)
+ (netcoredbg
+ modes (csharp-mode csharp-ts-mode)
+ ensure dape-ensure-command
+ command "netcoredbg"
+ command-args ["--interpreter=vscode"]
+ :request "launch"
+ :cwd dape-cwd-fn
+ :program dape-find-file
+ :stopAtEntry t))
"This variable holds the Dape configurations as an alist.
In this alist, the car element serves as a symbol identifying each
configuration. Each configuration, in turn, is a property list (plist)
@@ -62,6 +205,7 @@ where keys can be symbols or keywords.
Symbol Keys (Used by Dape):
- fn: Function takes config and returns config, used to apply changes
to config at runtime.
+- ensure: Function to ensure that adapter is available.
- command: Shell command to initiate the debug adapter.
- command-args: List of string arguments for the command.
- command-cwd: Working directory for the command.
@@ -425,7 +569,7 @@ DEFAULT specifies which file to return on empty input."
(expand-file-name
(read-file-name (if default
(format "Program (default %s): " default)
- "Program : ")
+ "Program: ")
default-directory
default t))))
@@ -449,6 +593,43 @@ DEFAULT specifies which file to return on empty input."
collection nil nil 'equal))
(read-number "Pid: ")))
+(defun dape-config-autoport (config)
+ "Replace occurences of `:autoport' in CONFIG `command-args' and `port'.
+Will replace symbol and string occurences of \"autoport\"."
+ ;; Stolen from `Eglot'
+ (let* ((port-probe (make-network-process :name "dape-port-probe-dummy"
+ :server t
+ :host "localhost"
+ :service 0))
+ (port-number (unwind-protect
+ (process-contact port-probe :service)
+ (delete-process port-probe)))
+ (port (if (eq (plist-get config 'port) :autoport)
+ port-number
+ (plist-get config 'port)))
+ (command-args (seq-map (lambda (item)
+ (cond
+ ((eq item :autoport)
+ (number-to-string port-number))
+ ((stringp item)
+ (string-replace ":autoport"
+ (number-to-string
port-number)
+ item))))
+ (plist-get config 'command-args))))
+ (let ((config
+ (thread-first config
+ (plist-put 'port port)
+ (plist-put 'command-args command-args))))
+ config)))
+
+(defun dape-ensure-command (config)
+ "Ensure that `command' from CONFIG exist system."
+ (let ((command
+ (dape--config-eval-value (plist-get config 'command))))
+ (unless (or (file-executable-p command)
+ (executable-find command))
+ (user-error "Unable to locate %S" command))))
+
(defun dape--overlay-region (&optional extended)
"List of beg and end of current line.
If EXTENDED end of line is after newline."
@@ -1514,6 +1695,8 @@ Use SKIP-COMPILE to skip compilation."
(erase-buffer)))))
(when-let ((fn (plist-get config 'fn)))
(setq config (funcall fn (copy-tree config))))
+ (when-let ((ensure (plist-get config 'ensure)))
+ (funcall ensure (copy-tree config)))
(cond
((and (not skip-compile) (plist-get config 'compile))
(dape--compile config))
@@ -2624,7 +2807,7 @@ apply."
"Helper for `dape--config-eval'."
(cl-loop for (key value) on config by 'cddr
append (cond
- ((memql key '(modes fn)) (list key value))
+ ((memql key '(modes fn ensure)) (list key value))
((and for-adapter (not (keywordp key)))
(user-error "Unexpected key %S; lists of things needs be \
arrays [%S ...], if meant as an object replace (%S ...) with (:%s ...)"
@@ -2667,7 +2850,7 @@ arrays [%S ...], if meant as an object replace (%S ...)
with (:%s ...)"
"Create a diff of config KEY and POST-EVAL config."
(let ((base-config (alist-get key dape-configs)))
(cl-loop for (key value) on post-eval by 'cddr
- unless (or (memql key '(modes fn)) ;; Skip modes
+ unless (or (memql key '(modes fn ensure)) ;; Skip meta params
(and
;; Does the key exist in `base-config'?
(plist-member base-config key)
@@ -2739,7 +2922,13 @@ or last mode valid history item from this session.
See `dape--config-mode-p' how \"valid\" is defined."
(let* ((suggested-configs
(cl-loop for (key . config) in dape-configs
- if (dape--config-mode-p config)
+ when (and (dape--config-mode-p config)
+ (condition-case nil
+ (or (funcall (or (plist-get config 'ensure)
+ 'identity)
+ config)
+ t)
+ (user-error nil)))
collect key))
(initial-contents
(or
- [elpa] externals/dape 2a478560e9 052/123: Move breakpoint indications into the buffer margin #2, (continued)
- [elpa] externals/dape 2a478560e9 052/123: Move breakpoint indications into the buffer margin #2, ELPA Syncer, 2023/12/05
- [elpa] externals/dape beaaca9c77 053/123: Fix missing server std out/err in debug buffer, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ad8d8797fa 054/123: Fix missing newline for "stopped" event description, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 9eebb3c246 055/123: Fix missing newline from compilation failed msg, ELPA Syncer, 2023/12/05
- [elpa] externals/dape d6d79670f7 056/123: Slight rework of dape--read-config, ELPA Syncer, 2023/12/05
- [elpa] externals/dape cbbb807604 050/123: Fix type in readme cppdbg adapter example #3, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ae98178a3e 064/123: Improve repl when adapter process non live, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 1d0cdcc466 070/123: Fix dape.el header #13, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 4a97094b10 077/123: Kill adapter on terminate event, ELPA Syncer, 2023/12/05
- [elpa] externals/dape bda32e7780 096/123: Fix issue of resetting start-debugging args #15, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ba63e50434 106/123: Batteries included,
ELPA Syncer <=
- [elpa] externals/dape 87c91273ec 107/123: Add error message on launch/attach fail, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 2620078517 117/123: Improve error message on failed restart, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 0f545358e2 118/123: Fix strange usage of add to watch in scope buffer, ELPA Syncer, 2023/12/05
- [elpa] externals/dape c3fb0ebc32 075/123: Remove `dape--name', ELPA Syncer, 2023/12/05
- [elpa] externals/dape bc17ae80ff 078/123: Fix debuggee cleanup, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 30b2695154 087/123: Cancel timeout timers on process kill, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 41cfcc3ce3 089/123: Variety of dape--tree-widget performance "hacks", ELPA Syncer, 2023/12/05
- [elpa] externals/dape b7c578992d 094/123: Fix unnecessary newline in stopped repl text, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 4c990a5769 110/123: Rename `dape-breakpoint-*' functions for discoverability, ELPA Syncer, 2023/12/05
- [elpa] externals/dape f02fc87e82 116/123: Fix fringe check when placing breakpoints, ELPA Syncer, 2023/12/05