2021-02-26 15:28:33 +00:00
|
|
|
;; -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;; node version manager
|
|
|
|
(use-package nvm
|
|
|
|
:commands (nvm-use
|
|
|
|
nvm-use-for
|
2021-04-05 14:44:49 +00:00
|
|
|
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))
|
2021-02-26 15:28:33 +00:00
|
|
|
|
|
|
|
(provide 'init-js)
|