;; -*- lexical-binding: t; -*- ;; node version manager (use-package nvm :commands (nvm-use nvm-use-for nvm-use-for-buffer nvm--installed-versions) :init (defun nvm (version) (interactive (list (completing-read "Node version: " (mapcar #'car (nvm--installed-versions))))) (nvm-use version))) (use-package js :straight (:type built-in) :defer t :config (add-hook 'js-mode-hook #'lsp-deferred)) ;; Make sure we load LSP in React files (with-eval-after-load 'lsp-clients (defun lsp-typescript-javascript-tsx-jsx-activate-p (filename major-mode) "Checks if the javascript-typescript language server should be enabled based on FILE-NAME and MAJOR-MODE" (or (member major-mode '(typescript-mode typescript-tsx-mode js-mode js2-mode rjsx-mode)) (and (eq major-mode 'web-mode) (or (string-suffix-p ".tsx" filename t) (string-suffix-p ".jsx" filename t) (string-suffix-p ".js" filename t)))))) (use-package js-comint :commands (run-js) :config (js-do-use-nvm) :general (js-mode-map "C-c M-j" #'run-js "C-x C-e" #'js-send-last-sexp "C-c C-k" #'js-send-buffer "C-c M-z" #'js-send-buffer-and-go)) (provide 'init-js)