-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup-js.el
49 lines (36 loc) · 1.38 KB
/
setup-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
42
43
44
45
46
47
48
49
;;; setup-js.el --- JavaScript
;;; Commentary:
;; javascript customizations
;;; Code:
(require 'js-comint)
(add-to-list 'auto-mode-alist '("\\.[c|m]?js\\'" . js2-mode))
(add-to-list 'interpreter-mode-alist '("node" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
(defun setup-tide-mode ()
"Tide mode setup according to the official guide."
(interactive)
(tide-setup)
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
(company-mode +1)
)
(defun inferior-js-mode-hook-setup ()
"Add hook according to the js-comint docs."
(add-hook 'comint-output-filter-functions 'js-comint-process-output))
(add-hook 'js2-mode-hook #'setup-tide-mode)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
(add-hook 'web-mode-hook
(lambda ()
(flycheck-add-mode 'typescript-tslint 'web-mode)
(when (string-equal "tsx" (file-name-extension buffer-file-name))
(setup-tide-mode))))
(add-hook 'inferior-js-mode-hook 'inferior-js-mode-hook-setup t)
(add-hook 'js2-mode-hook
(lambda ()
(flycheck-add-mode 'javascript-eslint 'js2-mode)
(local-set-key (kbd "C-c C-e") 'js-send-last-sexp)
(local-set-key (kbd "C-c C-b") 'js-send-buffer)
(local-set-key (kbd "C-c C-c") 'js-clear)
(local-set-key (kbd "C-c C-r") 'js-send-region)))
(provide 'setup-js)
;;; setup-js.el ends here