Hook up LSP for js/jsx

This commit is contained in:
Jeremy Dormitzer 2019-02-18 08:44:21 -05:00
parent d1d7b94043
commit ea9671b951

View File

@ -953,10 +953,21 @@ Some formatting stuff:
("\\.js\\'" . web-mode)
("\\.jsx\\'" . web-mode))
:config
(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)))))
(add-hook 'web-mode-hook
(lambda ()
(when (equal web-mode-content-type "javascript")
(web-mode-set-content-type "jsx")))))
(lambda ()
(when (equal web-mode-content-type "javascript")
(web-mode-set-content-type "jsx"))
(when (or (equal web-mode-content-type "javascript")
(equal web-mode-content-type "jsx"))
(lsp)))))
#+END_SRC
Use nvm to manage node versions: