forked from abo-abo/lispy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
le-js.el
41 lines (37 loc) · 1.3 KB
/
le-js.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
(require 'indium)
(defun lispy--eval-js (str)
(let ((r nil))
(indium-eval
str (lambda (value) (setq r (indium-render-remote-object-to-string value))))
(while (not r)
(accept-process-output))
(substring-no-properties r)))
(defun lispy--eval-js-str ()
(if (region-active-p)
(lispy--string-dwim)
(lispy--string-dwim
(lispy-bounds-python-block))))
(defun lispy--js-completion-at-point ()
(let* ((prefix (buffer-substring-no-properties
(let ((bol (point-at-bol))
(prev-delimiter (1+ (save-excursion
(re-search-backward "[([:space:]]" nil t)))))
(if prev-delimiter
(max bol prev-delimiter)
bol))
(point)))
(expression (if (string-match-p "\\." prefix)
(replace-regexp-in-string "\\.[^\\.]*$" "" prefix)
"this"))
(cands nil))
(indium-client-get-completion
expression
indium-debugger-current-frame
(lambda (candidates)
(setq cands candidates)))
(while (null cands)
(accept-process-output))
(list (- (point) (length (company-grab-symbol)))
(point)
(mapcar #'identity cands))))
(provide 'le-js)