Debian Codegraph @

ivette/src/dome/template/typescript.el

raw
1 ;;; -------------------------------------------------------------------------
2 ;;; Typescript Emacs Configuration
3 ;;;
4 ;;; (suggestions for populating your own .emacs file)
5 ;;; -------------------------------------------------------------------------
6
7 (defun setup-tide-mode ()
8 (interactive)
9 (tide-setup)
10 (flycheck-mode +1)
11 (setq flycheck-check-syntax-automatically '(save mode-enabled))
12 (eldoc-mode +1)
13 (tide-hl-identifier-mode +1)
14 ;; company is an optional dependency. You have to
15 ;; install it separately via package-install
16 ;; `M-x package-install [ret] company`
17 (company-mode +1))
18
19 (defun setup-tsx-mode ()
20 (interactive)
21 (when (string-equal "tsx" (file-name-extension buffer-file-name))
22 (setq web-mode-enable-auto-quoting nil)
23 (setup-tide-mode)))
24
25 ;; aligns annotation to the right hand side
26 (setq company-tooltip-align-annotations t)
27
28 ;; formats the buffer before saving
29 ;; (strongly recommanded to please es-linter)
30 (add-hook 'before-save-hook 'tide-format-before-save)
31
32 ;; Setup Tide for typescript
33 (add-hook 'typescript-mode-hook #'setup-tide-mode)
34
35 ;; Setup Tide for typescript with JSX syntax
36 (require 'web-mode)
37 (add-hook 'web-mode-hook #'setup-tsx-mode)
38
39 ;; Setup Typescript Indentation
40
41 (setq-default typescript-indent-level 2)
42 (setq-default web-mode-markup-indent-offset 2)
43 (setq-default web-mode-css-indent-offset 2)
44 (setq-default web-mode-code-indent-offset 2)
45
46 ;; Auto-mode Loading
47
48 (add-to-list 'auto-mode-alist '("\\.ts$" . typescript-mode))
49 (add-to-list 'auto-mode-alist '("\\.tsx$" . web-mode))
50
51 ;; Column mode
52
53 (safe-require fill-column-indicator
54 (setq-default fill-column 80)
55 (setq fci-rule-color "#8f8f8f")
56 (add-hook 'typescript-mode-hook 'fci-mode t)
57 (add-hook 'web-mode-hook 'fci-mode t))
58
59 ;; Compilation mode
60
61 (require 'compile)
62
63 ;;; TSC output
64 (add-to-list 'compilation-error-regexp-alist
65 '("^\\([a-zA-Z0-9_/.-]+.tsx?\\):\\([0-9]+\\):\\([0-9]+\\) - error" 1 2 3))
66
67 ;;; ES-Lint output
68 (add-to-list 'compilation-error-regexp-alist
69 '("^\\([a-zA-Z0-9_/.-]+.tsx?\\): line \\([0-9]+\\), col \\([0-9]+\\), Error" 1 2 3))
70
71 ;;; -------------------------------------------------------------------------