forked from emacs-lsp/dap-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdap-kotlin.el
55 lines (45 loc) · 2 KB
/
dap-kotlin.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
;; Commentary:
;; Adapter for https://github.com/fwcd/kotlin-debug-adapter
(require 'lsp-kotlin)
(require 'dap-mode)
(defcustom dap-kotlin-enable-log nil
"Turn on logging of debug adapter logs to file."
:type 'boolean
:group 'dap-kotlin)
(defcustom dap-kotlin-log-path nil
"Path to the debug adapter log file."
:type 'string
:group 'dap-kotlin)
(defun dap-kotlin-populate-launch-args (conf)
;; we require mainClass to be filled in in the launch configuration.
;; dap-kotlin does currently not support a fallback if not defined
(-> conf
(dap--put-if-absent :request "launch")
(dap--put-if-absent :name "Kotlin Launch")
(dap--put-if-absent :projectRoot (lsp-workspace-root))
(dap--put-if-absent :enableJsonLogging (lsp-json-bool dap-kotlin-enable-log))
(dap--put-if-absent :jsonLogFile dap-kotlin-log-path)))
(defun dap-kotlin-populate-attach-args (conf)
(-> conf
(dap--put-if-absent :request "attach")
(dap--put-if-absent :name "Kotlin Attach")
(dap--put-if-absent :projectRoot (lsp-workspace-root))
(dap--put-if-absent :hostName "localhost")
(dap--put-if-absent :port 5005)
(dap--put-if-absent :timeout 2000)
(dap--put-if-absent :enableJsonLogging (lsp-json-bool dap-kotlin-enable-log))
(dap--put-if-absent :jsonLogFile dap-kotlin-log-path)))
(defun dap-kotlin-populate-default-args (conf)
(setq conf (pcase (plist-get conf :request)
("launch" (dap-kotlin-populate-launch-args conf))
("attach" (dap-kotlin-populate-attach-args conf))
(_ (error "Unsupported dap-request"))))
(-> conf
(dap--put-if-absent :type "kotlin")
(plist-put :dap-server-path (list lsp-kotlin-debug-adapter-path))))
(dap-register-debug-provider "kotlin" #'dap-kotlin-populate-default-args)
(dap-register-debug-template "Kotlin Attach"
(list :type "kotlin"
:request "attach"
:noDebug nil))
(provide 'dap-kotlin)