typescript: fix usage of hooks in multiple backends setup
This is necessary as we use hack-local-variables-hook to setup the backends, at this time it is too late to setup hooks, we need to call the function right away.
This commit is contained in:
parent
0877f2f92a
commit
f4223543e1
|
@ -24,6 +24,12 @@
|
|||
(`tide (spacemacs//typescript-setup-tide-company))
|
||||
(`lsp (spacemacs//typescript-setup-lsp-company))))
|
||||
|
||||
(defun spacemacs//typescript-setup-eldoc ()
|
||||
"Conditionally setup eldoc based on backend."
|
||||
(pcase java-backend
|
||||
(`tide (spacemacs//typescript-setup-tide-eldoc))
|
||||
(`lsp (spacemacs//typescript-setup-lsp-eldoc))))
|
||||
|
||||
|
||||
;; tide
|
||||
|
||||
|
@ -34,12 +40,11 @@
|
|||
(kbd "C-k") 'tide-find-previous-reference
|
||||
(kbd "C-j") 'tide-find-next-reference
|
||||
(kbd "C-l") 'tide-goto-reference)
|
||||
(spacemacs/add-to-hooks 'tide-setup '(typescript-mode-hook
|
||||
typescript-tsx-mode-hook))
|
||||
(add-to-list 'spacemacs-jump-handlers-typescript-tsx-mode
|
||||
'(tide-jump-to-definition :async t))
|
||||
(add-to-list 'spacemacs-jump-handlers-typescript-mode
|
||||
'(tide-jump-to-definition :async t))))
|
||||
'(tide-jump-to-definition :async t))
|
||||
(tide-setup)))
|
||||
|
||||
(defun spacemacs//typescript-setup-tide-company ()
|
||||
"Setup tide auto-completion."
|
||||
|
@ -50,6 +55,10 @@
|
|||
company-minimum-prefix-length 2)
|
||||
(company-mode))
|
||||
|
||||
(defun spacemacs//typescript-setup-tide-eldoc ()
|
||||
"Setup eldoc for tide."
|
||||
(eldoc-mode))
|
||||
|
||||
|
||||
;; lsp
|
||||
|
||||
|
@ -57,11 +66,11 @@
|
|||
"Setup lsp backend."
|
||||
(if (configuration-layer/layer-used-p 'lsp)
|
||||
(progn
|
||||
(spacemacs/add-to-hooks #'lsp-javascript-typescript-enable
|
||||
'(typescript-mode-hook typescript-tsx-mode-hook) t)
|
||||
(spacemacs//setup-lsp-jump-handler 'typescript-mode
|
||||
'typescript-tsx-mode))
|
||||
(message "`lsp' layer is not installed, please add `lsp' layer to your dofile.")))
|
||||
'typescript-tsx-mode)
|
||||
(lsp-javascript-typescript-enable))
|
||||
(message (concat "`lsp' layer is not installed, "
|
||||
"please add `lsp' layer to your dofile."))))
|
||||
|
||||
(defun spacemacs//typescript-setup-lsp-company ()
|
||||
"Setup lsp auto-completion."
|
||||
|
@ -84,7 +93,12 @@
|
|||
:append-hooks nil
|
||||
:call-hooks t)
|
||||
(company-mode))
|
||||
(message "`lsp' layer is not installed, please add `lsp' layer to your dofile.")))
|
||||
(message (concat "`lsp' layer is not installed, "
|
||||
"please add `lsp' layer to your dofile."))))
|
||||
|
||||
(defun spacemacs//typescript-setup-lsp-eldoc ()
|
||||
"Setup eldoc for LSP."
|
||||
(eldoc-mode))
|
||||
|
||||
|
||||
;; Others
|
||||
|
|
|
@ -31,11 +31,10 @@
|
|||
'(typescript-mode-local-vars-hook
|
||||
typescript-tsx-mode-local-vars-hook)))
|
||||
|
||||
(defun typescript/pre-init-eldoc ()
|
||||
(spacemacs|use-package-add-hook tide
|
||||
:post-init
|
||||
(spacemacs/add-to-hooks 'eldoc-mode '(typescript-mode-hook
|
||||
typescript-tsx-mode-hook) t)))
|
||||
(defun typescript/post-init-eldoc ()
|
||||
(spacemacs/add-to-hooks #'spacemacs//typescript-setup-eldoc
|
||||
'(typescript-mode-local-vars-hook
|
||||
typescript-tsx-mode-local-vars-hook) t))
|
||||
|
||||
(defun typescript/post-init-flycheck ()
|
||||
(spacemacs/enable-flycheck 'typescript-mode)
|
||||
|
|
Loading…
Reference in a new issue