lang/javascript: add autoloaded cleanup & project-root functions
Forgot to add this to 605c897d
This commit is contained in:
parent
605c897d96
commit
9e45ad670c
1 changed files with 18 additions and 1 deletions
|
@ -78,7 +78,6 @@ Run this for any buffer you want to skewer."
|
||||||
(defun +javascript|add-node-modules-path ()
|
(defun +javascript|add-node-modules-path ()
|
||||||
"Search the current buffer's parent directories for `node_modules/.bin`.
|
"Search the current buffer's parent directories for `node_modules/.bin`.
|
||||||
If it's found, then add it to the `exec-path'."
|
If it's found, then add it to the `exec-path'."
|
||||||
(interactive)
|
|
||||||
(if-let* ((root (locate-dominating-file
|
(if-let* ((root (locate-dominating-file
|
||||||
(or (buffer-file-name) default-directory)
|
(or (buffer-file-name) default-directory)
|
||||||
"node_modules"))
|
"node_modules"))
|
||||||
|
@ -90,3 +89,21 @@ If it's found, then add it to the `exec-path'."
|
||||||
(message "Added %s to exec-path" path)))
|
(message "Added %s to exec-path" path)))
|
||||||
(when doom-debug-mode
|
(when doom-debug-mode
|
||||||
(message "node_modules not found in %s" root))))
|
(message "node_modules not found in %s" root))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +javascript|cleanup-tide-processes ()
|
||||||
|
"TODO"
|
||||||
|
(when tide-mode
|
||||||
|
(unless (cl-loop with root = (tide-project-root)
|
||||||
|
for buf in (delq (current-buffer) (buffer-list))
|
||||||
|
if (buffer-local-value 'tide-mode buf)
|
||||||
|
collect buf)
|
||||||
|
(kill-process (tide-current-server)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +javascript*tide-project-root ()
|
||||||
|
"Resolve to `doom-project-root' if `tide-project-root' fails."
|
||||||
|
(or tide-project-root
|
||||||
|
(or (locate-dominating-file default-directory "tsconfig.json")
|
||||||
|
(locate-dominating-file default-directory "jsconfig.json"))
|
||||||
|
(doom-project-root 'nocache)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue