Defer tide-mode init until file exists

This ensures that tide-mode won't activate for file-less JS buffers,
which are error prone. But once the file is saved, it will consider
activating itself.
This commit is contained in:
Henrik Lissner 2019-01-05 17:49:04 -05:00
parent b56639e31b
commit 681145e6b5
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -126,9 +126,11 @@
;; Don't let hard errors stop the user from opening js files.
(defun +javascript|init-tide ()
"Enable `tide-mode' if node is available."
(if (executable-find "node")
(tide-setup)
(message "Couldn't find `node', aborting tide server")))
(cond ((not buffer-file-name)
(add-hook 'after-save-hook #'+javascript|init-tide nil t))
((executable-find "node")
(tide-setup))
((message "Couldn't find `node', aborting tide server"))))
(add-hook! (js2-mode typescript-mode) #'+javascript|init-tide)
(defun +javascript|init-tide-in-web-mode ()