summaryrefslogtreecommitdiff
path: root/lisp/ts-custom.el
blob: 3054102e1e3e05a425b9d78d82e2b514572ac880 (plain)
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
(defun setup-ts()

  (use-package tide :ensure t)
  (use-package company :ensure t)
  (use-package flycheck :ensure t)
  (defun setup-tide-mode()
	(interactive)
	(tide-setup)
	(flycheck-mode +1)
	(setq web-mode-enable-auto-quoting nil)
    (setq web-mode-markup-indent-offset 2)
    (setq web-mode-code-indent-offset 2)
    (setq web-mode-attr-indent-offset 2)
    (setq web-mode-attr-value-indent-offset 2)	
	(setq flycheck-check-syntax-automatically '(save-mode-enabled))
	(eldoc-mode +1)
	(tide-hl-identifier-mode +1)
	(company-mode +1)
	(setq flycheck-check-syntax-automatically '(mode-enabled save)))
  
  (add-hook 'typescript-mode-hook #'setup-tide-mode)
  (add-hook 'before-save-hook 'tide-format-before-save)
  (require 'web-mode)

  (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
  (add-hook 'web-mode-hook
            (lambda ()
              (when (string-equal "tsx" (file-name-extension buffer-file-name))
                (setup-tide-mode))))
  
  ;; enable typescript - tslint checker
  (flycheck-add-mode 'typescript-tslint 'web-mode)) 

(provide 'ts-custom)