Merge branch 'jamestthompson3-develop' into develop
* jamestthompson3-develop: lang/javascript: remove mention of tern in README lang/javascript: remove company-tide package (doesn't exist) lang/javascript: conform to naming conventions; refactor tide config [*] Removes tern in favor of tide, adds node modules to path to execute things like flow, prettier, etc
This commit is contained in:
commit
929482a883
4 changed files with 37 additions and 32 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
This module adds Javascript support.
|
This module adds Javascript support.
|
||||||
|
|
||||||
+ Code completion (tern)
|
+ Code completion (tide)
|
||||||
+ REPL support (nodejs-repl)
|
+ REPL support (nodejs-repl)
|
||||||
+ Refactoring commands (js2-refactor)
|
+ Refactoring commands (js2-refactor)
|
||||||
+ Syntax checking (flycheck)
|
+ Syntax checking (flycheck)
|
||||||
|
@ -11,11 +11,10 @@ This module adds Javascript support.
|
||||||
+ Jump-to-definitions and references support (xref)
|
+ Jump-to-definitions and references support (xref)
|
||||||
|
|
||||||
* Table of Contents :TOC:
|
* Table of Contents :TOC:
|
||||||
- [[#install][Install]]
|
- [[Install][Install]]
|
||||||
- [[#node--npm][Node & NPM]]
|
- [[Node & NPM][Node & NPM]]
|
||||||
- [[#dependencies][Dependencies]]
|
- [[Appendix][Appendix]]
|
||||||
- [[#appendix][Appendix]]
|
- [[Commands][Commands]]
|
||||||
- [[#commands][Commands]]
|
|
||||||
|
|
||||||
* Install
|
* Install
|
||||||
** Node & NPM
|
** Node & NPM
|
||||||
|
@ -31,13 +30,6 @@ brew install node
|
||||||
sudo pacman --needed --noconfirm -S nodejs npm
|
sudo pacman --needed --noconfirm -S nodejs npm
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Dependencies
|
|
||||||
This module optionally requires ~tern~ for code completion.
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh
|
|
||||||
npm -g install tern
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* Appendix
|
* Appendix
|
||||||
** Commands
|
** Commands
|
||||||
| command | key / ex command | description |
|
| command | key / ex command | description |
|
||||||
|
|
|
@ -74,3 +74,19 @@ Run this for any buffer you want to skewer."
|
||||||
(if skewer-css-mode (skewer-css-mode -1))
|
(if skewer-css-mode (skewer-css-mode -1))
|
||||||
(if skewer-html-mode (skewer-html-mode -1)))))
|
(if skewer-html-mode (skewer-html-mode -1)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +javascript|add-node-modules-path ()
|
||||||
|
"Search the current buffer's parent directories for `node_modules/.bin`.
|
||||||
|
If it's found, then add it to the `exec-path'."
|
||||||
|
(interactive)
|
||||||
|
(if-let* ((root (locate-dominating-file
|
||||||
|
(or (buffer-file-name) default-directory)
|
||||||
|
"node_modules"))
|
||||||
|
(path (expand-file-name "node_modules/.bin/" root)))
|
||||||
|
(progn
|
||||||
|
(make-local-variable 'exec-path)
|
||||||
|
(cl-pushnew path exec-path :test #'string=)
|
||||||
|
(when doom-debug-mode
|
||||||
|
(message "Added %s to exec-path" path)))
|
||||||
|
(when doom-debug-mode
|
||||||
|
(message "node_modules not found in %s" root))))
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
js2-mode-show-parse-errors nil
|
js2-mode-show-parse-errors nil
|
||||||
js2-mode-show-strict-warnings nil)
|
js2-mode-show-strict-warnings nil)
|
||||||
|
|
||||||
(add-hook! 'js2-mode-hook #'(flycheck-mode rainbow-delimiters-mode))
|
(add-hook! 'js2-mode-hook
|
||||||
|
#'(flycheck-mode rainbow-delimiters-mode +javascript|add-node-modules-path))
|
||||||
|
|
||||||
(set! :repl 'js2-mode #'+javascript/repl)
|
(set! :repl 'js2-mode #'+javascript/repl)
|
||||||
(set! :electric 'js2-mode :chars '(?\} ?\) ?.))
|
(set! :electric 'js2-mode :chars '(?\} ?\) ?.))
|
||||||
|
@ -45,6 +46,17 @@
|
||||||
:n "S" #'+javascript/skewer-this-buffer))
|
:n "S" #'+javascript/skewer-this-buffer))
|
||||||
|
|
||||||
|
|
||||||
|
(def-package! tide
|
||||||
|
:hook (js2-mode . tide-setup)
|
||||||
|
:config
|
||||||
|
(set! :company 'js2-mode 'company-tide)
|
||||||
|
(set! :lookup 'js2-mode
|
||||||
|
:definition #'tide-jump-to-definition
|
||||||
|
:references #'tide-references
|
||||||
|
:documentation #'tide-documentation-at-point)
|
||||||
|
(add-hook! 'tide-mode-hook #'(eldoc-mode tide-hl-identifier-mode)))
|
||||||
|
|
||||||
|
|
||||||
;; A find-{definition,references} backend for js2-mode. NOTE The xref API is
|
;; A find-{definition,references} backend for js2-mode. NOTE The xref API is
|
||||||
;; unstable and may break with an Emacs update.
|
;; unstable and may break with an Emacs update.
|
||||||
(def-package! xref-js2
|
(def-package! xref-js2
|
||||||
|
@ -95,20 +107,6 @@
|
||||||
("Reformat buffer (eslint_d)" :exec eslintd-fix :region nil :when (fboundp 'eslintd-fix)))
|
("Reformat buffer (eslint_d)" :exec eslintd-fix :region nil :when (fboundp 'eslintd-fix)))
|
||||||
:prompt "Refactor: "))
|
:prompt "Refactor: "))
|
||||||
|
|
||||||
|
|
||||||
(def-package! tern
|
|
||||||
:hook (js2-mode . tern-mode)
|
|
||||||
:config
|
|
||||||
(advice-add #'tern-project-dir :override #'doom-project-root))
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! company-tern
|
|
||||||
:when (featurep! :completion company)
|
|
||||||
:after tern
|
|
||||||
:config
|
|
||||||
(set! :company-backend 'js2-mode '(company-tern)))
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! rjsx-mode
|
(def-package! rjsx-mode
|
||||||
:commands rjsx-mode
|
:commands rjsx-mode
|
||||||
:mode "\\.jsx$"
|
:mode "\\.jsx$"
|
||||||
|
@ -132,6 +130,8 @@
|
||||||
"<" nil
|
"<" nil
|
||||||
"C-d" nil)
|
"C-d" nil)
|
||||||
(add-hook! rjsx-mode
|
(add-hook! rjsx-mode
|
||||||
|
|
||||||
|
#'(flycheck-mode set-up-tide-mode add-node-modules-path rainbow-delimiters-mode)
|
||||||
;; jshint doesn't really know how to deal with jsx
|
;; jshint doesn't really know how to deal with jsx
|
||||||
(push 'javascript-jshint flycheck-disabled-checkers)))
|
(push 'javascript-jshint flycheck-disabled-checkers)))
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,11 @@
|
||||||
(package! js2-refactor)
|
(package! js2-refactor)
|
||||||
(package! rjsx-mode)
|
(package! rjsx-mode)
|
||||||
(package! nodejs-repl)
|
(package! nodejs-repl)
|
||||||
(package! tern)
|
|
||||||
(package! web-beautify)
|
(package! web-beautify)
|
||||||
|
(package! tide)
|
||||||
(package! skewer-mode)
|
(package! skewer-mode)
|
||||||
(package! eslintd-fix)
|
(package! eslintd-fix)
|
||||||
|
|
||||||
(when (featurep! :completion company)
|
|
||||||
(package! company-tern))
|
|
||||||
|
|
||||||
(when (featurep! :feature lookup)
|
(when (featurep! :feature lookup)
|
||||||
(package! xref-js2))
|
(package! xref-js2))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue