lang/typescript: refactor + fix project root resolution
This commit is contained in:
parent
dd24578657
commit
46c31e7f0a
1 changed files with 17 additions and 24 deletions
|
@ -4,23 +4,16 @@
|
||||||
:mode "\\.ts$"
|
:mode "\\.ts$"
|
||||||
:config
|
:config
|
||||||
(add-hook 'typescript-mode-hook #'rainbow-delimiters-mode)
|
(add-hook 'typescript-mode-hook #'rainbow-delimiters-mode)
|
||||||
|
(set! :electric 'typescript-mode :chars '(?\} ?\)) :words '("||" "&&")))
|
||||||
(set! :electric 'typescript-mode :chars '(?\} ?\)) :words '("||" "&&"))
|
|
||||||
|
|
||||||
;; TODO tide-jump-back
|
|
||||||
;; TODO (tide-jump-to-definition t)
|
|
||||||
;; TODO convert into keybinds
|
|
||||||
;; (set! :emr 'typescript-mode
|
|
||||||
;; '(tide-find-references "find usages")
|
|
||||||
;; '(tide-rename-symbol "rename symbol")
|
|
||||||
;; '(tide-jump-to-definition "jump to definition")
|
|
||||||
;; '(tide-documentation-at-point "current type documentation")
|
|
||||||
;; '(tide-restart-server "restart tide server"))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! tide
|
(def-package! tide
|
||||||
:after typescript-mode
|
:hook (typescript-mode . tide-setup)
|
||||||
|
:init
|
||||||
|
(defun +typescript|init-tide-in-web-mode ()
|
||||||
|
(when (string= (file-name-extension (or buffer-file-name "")) "tsx")
|
||||||
|
(tide-setup)))
|
||||||
|
(add-hook 'web-mode-hook #'+typescript|init-tide-in-web-mode)
|
||||||
:config
|
:config
|
||||||
(set! :company-backend 'typescript-mode '(company-tide))
|
(set! :company-backend 'typescript-mode '(company-tide))
|
||||||
(set! :lookup 'typescript-mode
|
(set! :lookup 'typescript-mode
|
||||||
|
@ -32,14 +25,14 @@
|
||||||
'(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t
|
'(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t
|
||||||
:placeOpenBraceOnNewLineForFunctions nil))
|
:placeOpenBraceOnNewLineForFunctions nil))
|
||||||
|
|
||||||
(defun +typescript|init-tide ()
|
(def-menu! +typescript/refactor-menu
|
||||||
(when (or (eq major-mode 'typescript-mode)
|
"TODO"
|
||||||
(and (eq major-mode 'web-mode)
|
'(("rename symbol" :exec tide-rename-symbol)
|
||||||
buffer-file-name
|
("restart tide server" :exec tide-restart-server)))
|
||||||
(equal (file-name-extension buffer-file-name) "tsx")))
|
|
||||||
(tide-setup)
|
(map! :map tide-mode-map
|
||||||
(flycheck-mode +1)
|
:localleader
|
||||||
(eldoc-mode +1)
|
:n "r" #'+typescript/refactor-menu)
|
||||||
(setq tide-project-root (doom-project-root))))
|
|
||||||
(add-hook! (typescript-mode web-mode) #'+typescript|init-tide))
|
(add-hook! 'tide-mode-hook #'(flycheck-mode eldoc-mode)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue