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 Apr 22, 2024
1 parent 302fb05 commit 15e980d
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions dap-firefox.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,46 @@

(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 (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 15e980d

Please sign in to comment.