-
Notifications
You must be signed in to change notification settings - Fork 0
/
company-d.el
61 lines (47 loc) · 1.67 KB
/
company-d.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
56
57
58
59
60
61
;;; company-d.el --- company-mode backend for D Lang (using DCD)
;; Version: 20150315
;; Copyright (C) 2015
;; Author: slevin <slevin@gmail.com>
;; Keywords: languages
;; Package-Requires: ((company "0.8.0"))
;; No license, this code is under public domain, do whatever you want.
;; Lots of advice from company-go
;;; Code:
(eval-after-load "d-mode"
'(progn
(start-process "DVD-server" "*dcd-server*" "dcd-server" "-p" "2000")))
(defun company-d--prefix ()
(company-grab-symbol-cons "\\." 1)
)
(defun company-d--process-candidates (results)
;;(message "%s" results)
(let ((res (split-string results "\n" t "[ \f\t\n\r\v]+")))
(if (string= (car res) "identifiers")
(mapcar (lambda (str)
(car (split-string str "\t"))
)
(cdr res))
'())))
(defun company-d (command &optional arg &rest ignored)
;(message "%s : %s" command arg)
(case command
(prefix (and (derived-mode-p 'd-mode)
(not (company-in-string-or-comment))
(or (company-d--prefix) 'stop)))
(candidates
(let ((temp-buffer (generate-new-buffer "*dcd-client*")))
(prog2
(call-process-region (point-min)
(point-max)
"dcd-client"
nil
temp-buffer
nil
(format "-c%d" (point)))
(with-current-buffer temp-buffer
(company-d--process-candidates (buffer-string)))
(kill-buffer temp-buffer))))
))
(provide 'company-d)
;; split out return type
;;; company-d.el ends here