refactor(javascript): remove vestigial tide/skewer functions

Amend: bd0bee92cc
This commit is contained in:
Henrik Lissner
2025-08-31 18:38:24 +02:00
parent 3e7a20f972
commit 247b630cbd

View File

@@ -47,84 +47,7 @@ ignore the cache."
;;;###autoload
(defun +javascript/open-repl ()
"Open a Javascript REPL. Meaning either `skewer-repl', if any of the
skewer-*-mode's are enabled, or `nodejs-repl' otherwise."
"Open a Javascript REPL via `nodejs-repl'."
(interactive)
(call-interactively
(if (and (featurep 'skewer-mode)
(or (bound-and-true-p skewer-mode)
(bound-and-true-p skewer-css-mode)
(bound-and-true-p skewer-html-mode)))
#'skewer-repl
#'nodejs-repl))
(nodejs-repl)
(current-buffer))
;;;###autoload
(defun +javascript/skewer-this-buffer ()
"Toggle a globalized skewer-mode, attaching an external browser (once),
initiating an internal httpd server (once) and enabling the appropriate
skewer-mode for the current buffer.
Run this for any buffer you want to skewer."
(interactive)
(when (bound-and-true-p impatient-mode)
(error "Skewer-mode isn't compatible with impatient mode"))
(require 'skewer-mode)
(unless (process-status "httpd")
(run-skewer))
(pcase major-mode
((or 'css-mode 'scss-mode 'less-css-mode)
(unless (bound-and-true-p skewer-css-mode)
(skewer-css-mode +1)))
((or 'web-mode 'html-mode)
(unless (bound-and-true-p skewer-html-mode)
(skewer-html-mode +1)))
('js2-mode
(unless (bound-and-true-p skewer-mode)
(skewer-mode +1)))
(_ (error "Invalid mode %s" major-mode))))
;;;###autoload
(defun +javascript/skewer-cleanup ()
"Disable skewer-mode globally and disable the httpd server."
(interactive)
(when (process-status "httpd")
(httpd-stop))
(dolist (buf (buffer-list))
(with-current-buffer buf
(if (bound-and-true-p skewer-mode)
(skewer-mode -1))
(if (bound-and-true-p skewer-css-mode)
(skewer-css-mode -1))
(if (bound-and-true-p skewer-html-mode)
(skewer-html-mode -1)))))
;;
;; Hooks
;;;###autoload
(defun +javascript-cleanup-tide-processes-h ()
"Clean up dangling tsserver processes if there are no more buffers with
`tide-mode' active that belong to that server's project."
(when tide-mode
(unless (cl-loop with project-name = (tide-project-name)
for buf in (delq (current-buffer) (buffer-list))
if (and (buffer-local-value 'tide-mode buf)
(with-current-buffer buf
(string= (tide-project-name) project-name)))
return buf)
(kill-process (tide-current-server)))))
;;
;; Advice
;;;###autoload
(defun +javascript-tide-project-root-a ()
"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"))
(or (doom-project-root)
default-directory)))