-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsx-setup.el
93 lines (81 loc) · 2.63 KB
/
tsx-setup.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(use-package flycheck
:ensure t
:config
(add-hook 'typescript-mode-hook 'flycheck-mode))
(defun setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
(company-mode +1))
(use-package company
:ensure t
:config
;; invert the navigation direction if the the completion popup-isearch-match
;; is displayed on top (happens near the bottom of windows)
(setq company-tooltip-flip-when-above t
;;company-show-numbers t
company-tooltip-align-annotations t
company-minimun-prefix-lengh 1
company-idel-delay 0.0)
(global-company-mode))
(use-package company-quickhelp
:ensure t
:init
(company-quickhelp-mode 1)
(use-package pos-tip
:ensure t))
(use-package web-mode
:ensure t
:mode (("\\.html?\\'" . web-mode)
("\\.tsx\\'" . web-mode)
("\\.jsx\\'" . web-mode))
:config
(setq web-mode-markup-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2
web-mode-block-padding 2
web-mode-comment-style 2
web-mode-enable-css-colorization t
web-mode-enable-auto-pairing t
web-mode-enable-comment-keywords t
web-mode-enable-current-element-highlight t
web-mode-enable-auto-indentation nil
)
(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))
(use-package typescript-mode
:ensure t
:config
(setq typescript-indent-level 2)
(add-hook 'typescript-mode #'subword-mode))
(use-package tide
:init
:ensure t
:after (typescript-mode company flycheck)
:hook ((typescript-mode . tide-setup)
(typescript-mode . tide-hl-identifier-mode)))
(use-package css-mode
:config
(setq css-indent-offset 2))
;; Fixes tide-server start
(setq tide-node-executable "/Users/rafaeltauil/.nvm/versions/node/v18.17.1/bin/node")
(setq exec-path (append exec-path '("/Users/rafaeltauil/.nvm/versions/node/v18.17.1/bin/node")))
;; Adds to path so all binaries works within magit
(setenv "PATH" (concat (getenv "PATH") ":/Users/rafaeltauil/.nvm/versions/node/v18.17.1/bin"))
(use-package prettier
:ensure t
:hook ((rjsx-mode . prettier-mode)
(typescript-mode . prettier-mode)
(web-mode . prettier-mode)))
(use-package lsp-mode
:ensure t
:commands (lsp lsp-deferred)
:init (setq lsp-keymap-prefix "C-c l")
:config (lsp-enable-which-key-integration t))