|
| 1 | +;;; dap-swi-prolog.el --- Debug Adapter Protocol mode for SWI-Prolog -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2021 Eshel Yaron |
| 4 | + |
| 5 | +;; Author: Eshel Yaron <[email protected]> |
| 6 | +;; Keywords: languages |
| 7 | + |
| 8 | +;; This program is free software; you can redistribute it and/or modify |
| 9 | +;; it under the terms of the GNU General Public License as published by |
| 10 | +;; the Free Software Foundation, either version 3 of the License, or |
| 11 | +;; (at your option) any later version. |
| 12 | + |
| 13 | +;; This program is distributed in the hope that it will be useful, |
| 14 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +;; GNU General Public License for more details. |
| 17 | + |
| 18 | +;; You should have received a copy of the GNU General Public License |
| 19 | +;; along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + |
| 21 | +;; URL: https://github.com/yyoncho/dap-mode |
| 22 | +;; Package-Requires: ((emacs "25.1") (dash "2.14.1") (lsp-mode "4.0")) |
| 23 | +;; Version: 0.2 |
| 24 | + |
| 25 | +;;; Commentary: |
| 26 | +;; Adapter for https://www.swi-prolog.org |
| 27 | + |
| 28 | +;;; Code: |
| 29 | + |
| 30 | +(require 'dap-mode) |
| 31 | + |
| 32 | +(defcustom dap-swi-prolog-debug-program |
| 33 | + `(,(locate-file "swipl_debug_adapter" exec-path)) |
| 34 | + "The path to the SWI-Prolog debug adapter." |
| 35 | + :group 'dap-swi-prolog |
| 36 | + :type '(repeat string)) |
| 37 | + |
| 38 | +(defun dap-swi-prolog--populate-start-file-args (conf) |
| 39 | + "Populate CONF with the required arguments." |
| 40 | + (let ((conf (-> conf |
| 41 | + (dap--put-if-absent :dap-server-path dap-swi-prolog-debug-program) |
| 42 | + (dap--put-if-absent :type "swi-prolog") |
| 43 | + (dap--put-if-absent :cwd default-directory) |
| 44 | + (dap--put-if-absent :module (buffer-file-name)) |
| 45 | + (dap--put-if-absent :goal (read-string "Goal: " nil nil "true")) |
| 46 | + (dap--put-if-absent :name "SWI-Prolog Debug")))) |
| 47 | + conf)) |
| 48 | + |
| 49 | +(dap-register-debug-provider "swi-prolog" #'dap-swi-prolog--populate-start-file-args) |
| 50 | + |
| 51 | +(dap-register-debug-template "SWI-Prolog Run Configuration" |
| 52 | + (list :type "swi-prolog" |
| 53 | + :request "launch" |
| 54 | + :name "SWI-Prolog::Run")) |
| 55 | + |
| 56 | +(provide 'dap-swi-prolog) |
| 57 | +;;; dap-swi-prolog.el ends here |
0 commit comments