-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.el
53 lines (43 loc) · 1.53 KB
/
javascript.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
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.json$" . js2-mode))
(defadvice js2-reparse (before json)
(setq js2-buffer-file-name buffer-file-name))
(ad-activate 'js2-reparse)
(defadvice js2-parse-statement (around json)
(if (and (= tt js2-LC)
js2-buffer-file-name
(string-equal (substring js2-buffer-file-name -5) ".json")
(eq (+ (save-excursion
(goto-char (point-min))
(back-to-indentation)
(while (eolp)
(next-line)
(back-to-indentation))
(point)) 1) js2-ts-cursor))
(setq ad-return-value (js2-parse-assign-expr))
ad-do-it))
(ad-activate 'js2-parse-statement)
(add-hook 'javascript-mode-hook
'(lambda()
(yas/minor-mode-on)))
(defun js2-newline-key ()
(interactive)
(let ((parse-status (save-excursion
(parse-partial-sexp (point-min) (point)))))
(if (nth 4 parse-status)
;; check if inside a block comment
(js2-mode-extend-comment)
(newline-and-indent)
)
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Javascript keybindings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun noah-add-js2-keys ()
(local-set-key (kbd "C-j") 'js2-newline-key))
(add-hook 'js2-mode-hook 'noah-add-js2-keys)
(setq js2-missing-semi-one-line-override t)
(eval-after-load 'js2-mode
'(progn
(define-key js2-mode-map (kbd "C-c C-d") 'js2-next-error)))