Skip to content

Commit

Permalink
fix: dap-firefox
Browse files Browse the repository at this point in the history
Shamelessly stolen from: emacs-lsp#755
  • Loading branch information
zeorin committed Nov 1, 2024
1 parent 96a8f74 commit eb27d0a
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions dap-firefox.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,44 @@

(defun dap-firefox--populate-start-file-args (conf)
"Populate CONF with the required arguments."
(-> conf
(dap--put-if-absent :dap-server-path dap-firefox-debug-program)
(dap--put-if-absent :type "Firefox")
(dap--put-if-absent :cwd default-directory)
(dap--put-if-absent :file (expand-file-name (read-file-name "Select the file to open in the browser:" nil (buffer-file-name) t)))
(dap--put-if-absent :name "Firefox Debug")))
(setq conf (-> conf
(plist-put :type "firefox")
(plist-put :dap-server-path dap-firefox-debug-program)
(dap--put-if-absent :cwd (expand-file-name default-directory))))
(dap--plist-delete
(pcase (plist-get conf :mode)
("url" (-> conf
(dap--put-if-absent :url (read-string
"Browse url: "
"http://localhost:5371" t))
(dap--put-if-absent :webRoot (lsp-workspace-root))))
("file" (dap--put-if-absent conf :file
(read-file-name "Select the file to open in the browser:" nil (buffer-file-name) t)))
(_ conf))
:mode))

(dap-register-debug-provider "firefox" 'dap-firefox--populate-start-file-args)

(dap-register-debug-template "Firefox Run Configuration"
(dap-register-debug-template "Firefox Browse File"
(list :type "firefox"
:mode "file"
:cwd nil
:request "launch"
:file nil
:reattach t
:program nil
:name "Firefox Browse File"))

(dap-register-debug-template "Firefox Browse URL"
(list :type "firefox"
:mode "url"
:cwd nil
:request "launch"
:webRoot nil
:url nil
:reAttach t
:program nil
:name "Firefox::Run"))
:name "Firefox Browse URL"))

(provide 'dap-firefox)
;;; dap-firefox.el ends here

0 comments on commit eb27d0a

Please sign in to comment.