Skip to content

Commit

Permalink
Initial integration of the new node js debugger (#733)
Browse files Browse the repository at this point in the history
* Initial integration of the new node js debugger

* Added automatic download
  • Loading branch information
yyoncho authored Nov 13, 2023
1 parent f6706fa commit c99c103
Show file tree
Hide file tree
Showing 24 changed files with 201 additions and 97 deletions.
2 changes: 1 addition & 1 deletion dap-chrome.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.2

Expand Down
2 changes: 1 addition & 1 deletion dap-dlv-go.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; 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

Expand Down
2 changes: 1 addition & 1 deletion dap-edge.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.2

Expand Down
2 changes: 1 addition & 1 deletion dap-elixir.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.2

Expand Down
2 changes: 1 addition & 1 deletion dap-erlang.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.2

Expand Down
2 changes: 1 addition & 1 deletion dap-firefox.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.2

Expand Down
2 changes: 1 addition & 1 deletion dap-gdb-lldb.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Version: 0.2

;;; Commentary:
Expand Down
2 changes: 1 addition & 1 deletion dap-gdscript.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.1

Expand Down
2 changes: 1 addition & 1 deletion dap-go.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.2

Expand Down
2 changes: 1 addition & 1 deletion dap-hydra.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (hydra "0.14.0"))
;; Version: 0.2
;; Hydra
Expand Down
80 changes: 80 additions & 0 deletions dap-js.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
;;; dap-js.el --- Debug Adapter Protocol mode for Node -*- lexical-binding: t; -*-

;; Copyright (C) Ivan Yonchovski

;; Author: Ivan Yonchovski <[email protected]>
;; Keywords: languages

;; 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 <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-js-path (expand-file-name "js-debug" dap-utils-extension-path)
"The path to the place at which the webfreak.debug extension.
Link: https://marketplace.visualstudio.com/items?itemName=webfreak.debug ."
:group 'dap-js
:type 'string)

(defcustom dap-js-debug-program `("node" ,(f-join dap-js-path "src" "dapDebugServer.js"))
"The path to the JS debugger."
:group 'dap-js
:type '(repeat string))

(defun dap-js-setup (&optional forced)
"Downloading webfreak.debug to path specified.
With prefix, FORCED to redownload the extension."
(interactive "P")
(unless (and (not forced) (file-exists-p dap-js-path))
(lsp-download-install
(lambda (&rest _) (lsp--info "Downloaded extension!"))
(lambda (error) (lsp--error "Failed Downloaded extension %s!" error))
:url (lsp--find-latest-gh-release-url
"https://api.github.com/repos/microsoft/vscode-js-debug/releases/latest"
"js-debug-dap")
:store-path dap-js-path
:decompress :targz)))

(defun dap-js--populate-start-file-args (conf)
"Populate CONF with the required arguments."
(let ((port (dap--find-available-port)))
(-> conf
(append
(list :debugServer port
:host "localhost"
:type "pwa-node"
:program-to-start (concat (s-join " " dap-js-debug-program)
" "
(number-to-string port))))
(dap--put-if-absent :cwd default-directory)
(dap--put-if-absent :name "Node Debug"))))

(dap-register-debug-provider "pwa-node" #'dap-js--populate-start-file-args)

(dap-register-debug-template
"Node Run Configuration (new)"
(list :type "pwa-node"
:cwd nil
:request "launch"
:program nil
:name "Node::Run"))

(provide 'dap-js)
;;; dap-js.el ends here
2 changes: 1 addition & 1 deletion dap-lldb.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 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
;; URL: https://github.com/emacs-lsp/dap-mode
;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0"))
;; Version: 0.2

Expand Down
Loading

0 comments on commit c99c103

Please sign in to comment.