Skip to content

Commit 6f46e11

Browse files
committed
le-js.el: Add support for JavaScript via Indium
1 parent dbab589 commit 6f46e11

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

le-js.el

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
(require 'indium)
2+
3+
(defun lispy--eval-js (str)
4+
(let ((r nil))
5+
(indium-eval
6+
str (lambda (value) (setq r (indium-render-remote-object-to-string value))))
7+
(while (not r)
8+
(accept-process-output))
9+
(substring-no-properties r)))
10+
11+
(defun lispy--eval-js-str ()
12+
(if (region-active-p)
13+
(lispy--string-dwim)
14+
(lispy--string-dwim
15+
(lispy-bounds-python-block))))
16+
17+
(defun lispy--js-completion-at-point ()
18+
(let* ((prefix (buffer-substring-no-properties
19+
(let ((bol (point-at-bol))
20+
(prev-delimiter (1+ (save-excursion
21+
(re-search-backward "[([:space:]]" nil t)))))
22+
(if prev-delimiter
23+
(max bol prev-delimiter)
24+
bol))
25+
(point)))
26+
(expression (if (string-match-p "\\." prefix)
27+
(replace-regexp-in-string "\\.[^\\.]*$" "" prefix)
28+
"this"))
29+
(cands nil))
30+
(indium-client-get-completion
31+
expression
32+
indium-debugger-current-frame
33+
(lambda (candidates)
34+
(setq cands candidates)))
35+
(while (null cands)
36+
(accept-process-output))
37+
(list (- (point) (length (company-grab-symbol)))
38+
(point)
39+
(mapcar #'identity cands))))
40+
41+
(provide 'le-js)

lispy.el

+2
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,8 @@ SYMBOL is a string."
41984198
le-clojure lispy-eval-clojure)
41994199
(python-mode
42004200
le-python lispy--eval-python lispy-eval-python-str lispy-eval-python-bnd)
4201+
(js2-mode
4202+
le-js lispy--eval-js lispy--eval-js-str)
42014203
(julia-mode
42024204
le-julia lispy-eval-julia lispy-eval-julia-str)
42034205
(racket-mode

0 commit comments

Comments
 (0)