Skip to content

Commit 096070a

Browse files
authored
Add support for OCaml through Earlybird (#750)
1 parent de41d62 commit 096070a

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

dap-ocaml.el

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
;;; dap-mode/dap-ocaml.el -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2018 Austin Theriault
4+
5+
;; Author: Austin Theriault <[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 OCaml Earlybird (https://github.com/hackwaly/ocamlearlybird)
27+
28+
;;; Code:
29+
30+
(require 'dap-mode)
31+
32+
(defcustom dap-ocaml-executable "ocamlearlybird"
33+
"Path to the OCaml Earlybird executable."
34+
:group 'dap-ocaml
35+
:risky t
36+
:type 'file)
37+
38+
(defun dap-ocaml--populate-start-file-args (conf)
39+
"Populate CONF with the start file argument."
40+
(-> conf
41+
(dap--put-if-absent :console "internalConsole") ;; integratedTerminal doesn't work
42+
(dap--put-if-absent :dap-server-path (list dap-ocaml-executable "debug"))))
43+
44+
(dap-register-debug-provider "ocaml.earlybird" 'dap-ocaml--populate-start-file-args)
45+
(dap-register-debug-template "OCaml Debug Template"
46+
(list :type "ocaml.earlybird"
47+
:request "launch"
48+
:name "OCaml::Run"
49+
:program nil
50+
:arguments nil))
51+
52+
53+
(provide 'dap-ocaml)
54+
;;; dap-ocaml.el ends here

docs/page/configuration.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,3 +656,23 @@ Core Attach (Console)" from `dap-debug` menu.
656656
2. Usage
657657
658658
Call `dap-debug` and select the "Unity Editor" template
659+
660+
## OCaml
661+
662+
[earlybird](https://github.com/hackwaly/ocamlearlybird) is an OCaml debugger with support for DAP.
663+
664+
1. Installation
665+
666+
- Install earlybird through `opam install earlybird`
667+
668+
- Put in your configuration file:
669+
670+
``` elisp
671+
(require 'dap-ocaml)
672+
```
673+
674+
2. Usage
675+
676+
Call `dap-debug` and edit the "OCaml Debug Template". Make sure to set the program field as the path of your *byte-code* compiled program.
677+
Note that this debugger _only_ works with bytecode compiled OCaml programs.
678+

0 commit comments

Comments
 (0)