Use add-node-modules-path to automatically find local executables
This commit is contained in:
parent
55ceef53a5
commit
09ce56df3d
|
@ -23,18 +23,3 @@
|
|||
(web-mode-set-content-type "jsx")
|
||||
;; Don't auto-quote attribute values
|
||||
(setq-local web-mode-enable-auto-quoting nil))
|
||||
|
||||
|
||||
;; flycheck
|
||||
|
||||
(defun spacemacs//react-use-eslint-from-node-modules ()
|
||||
(let* ((root (locate-dominating-file
|
||||
(or (buffer-file-name) default-directory)
|
||||
"node_modules"))
|
||||
(global-eslint (executable-find "eslint"))
|
||||
(local-eslint (expand-file-name "node_modules/.bin/eslint"
|
||||
root))
|
||||
(eslint (if (file-executable-p local-eslint)
|
||||
local-eslint
|
||||
global-eslint)))
|
||||
(setq-local flycheck-javascript-eslint-executable eslint)))
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
(with-eval-after-load 'flycheck
|
||||
(dolist (checker '(javascript-eslint javascript-standard))
|
||||
(flycheck-add-mode checker 'react-mode)))
|
||||
(add-hook 'react-mode-hook #'spacemacs//react-use-eslint-from-node-modules)
|
||||
(spacemacs/enable-flycheck 'react-mode))
|
||||
|
||||
(defun react/post-init-js-doc ()
|
||||
|
|
12
layers/+lang/html/layers.el
Normal file
12
layers/+lang/html/layers.el
Normal file
|
@ -0,0 +1,12 @@
|
|||
;;; layers.el --- HTML Layer layers File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(configuration-layer/declare-layers '(node))
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
(setq html-packages
|
||||
'(
|
||||
add-node-modules-path
|
||||
company
|
||||
(company-web :toggle (configuration-layer/package-usedp 'company))
|
||||
css-mode
|
||||
|
@ -30,6 +31,15 @@
|
|||
yasnippet
|
||||
))
|
||||
|
||||
(defun html/post-init-add-node-modules-path ()
|
||||
(add-hook 'css-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'less-css-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'pug-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'sass-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'scss-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'slim-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'web-mode-hook #'add-node-modules-path))
|
||||
|
||||
(defun html/post-init-company ()
|
||||
(spacemacs|add-company-backends
|
||||
:backends company-css
|
||||
|
|
12
layers/+lang/javascript/layers.el
Normal file
12
layers/+lang/javascript/layers.el
Normal file
|
@ -0,0 +1,12 @@
|
|||
;;; layers.el --- Javascript Layer layers File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(configuration-layer/declare-layers '(node))
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
(setq javascript-packages
|
||||
'(
|
||||
add-node-modules-path
|
||||
coffee-mode
|
||||
company
|
||||
(company-tern :toggle (configuration-layer/package-usedp 'company))
|
||||
|
@ -29,6 +30,12 @@
|
|||
livid-mode
|
||||
))
|
||||
|
||||
(defun javascript/post-init-add-node-modules-path ()
|
||||
(add-hook 'css-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'coffee-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'js2-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'json-mode-hook #'add-node-modules-path))
|
||||
|
||||
(defun javascript/init-coffee-mode ()
|
||||
(use-package coffee-mode
|
||||
:defer t
|
||||
|
|
12
layers/+lang/typescript/layers.el
Normal file
12
layers/+lang/typescript/layers.el
Normal file
|
@ -0,0 +1,12 @@
|
|||
;;; layers.el --- typescript Layer layers File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Chris Bowdon <c.bowdon@bath.edu>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(configuration-layer/declare-layers '(node))
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
(setq typescript-packages
|
||||
'(
|
||||
add-node-modules-path
|
||||
company
|
||||
eldoc
|
||||
flycheck
|
||||
|
@ -19,6 +20,10 @@
|
|||
web-mode
|
||||
))
|
||||
|
||||
(defun typescript/post-init-add-node-modules-path ()
|
||||
(add-hook 'typescript-mode-hook #'add-node-modules-path)
|
||||
(add-hook 'web-mode-hook #'add-node-modules-path))
|
||||
|
||||
(defun typescript/post-init-company ()
|
||||
(when (configuration-layer/package-usedp 'tide)
|
||||
(spacemacs|add-company-backends
|
||||
|
|
10
layers/+tools/node/README.org
Normal file
10
layers/+tools/node/README.org
Normal file
|
@ -0,0 +1,10 @@
|
|||
#+TITLE: Node layer
|
||||
|
||||
[[file:img/node.png]]
|
||||
|
||||
* Table of Contents :TOC_4_gh:noexport:
|
||||
- [[#description][Description]]
|
||||
|
||||
* Description
|
||||
This layer introduces packages that target Node.js. Currently this layer should
|
||||
not be used directly, as it will be used by other layers.
|
BIN
layers/+tools/node/img/node.png
Normal file
BIN
layers/+tools/node/img/node.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
18
layers/+tools/node/packages.el
Normal file
18
layers/+tools/node/packages.el
Normal file
|
@ -0,0 +1,18 @@
|
|||
;;; packages.el --- node layer packages file for Spacemacs.
|
||||
;;
|
||||
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Juan Placencia <juan.placencia.512@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(setq node-packages
|
||||
'(
|
||||
add-node-modules-path
|
||||
))
|
||||
|
||||
(defun node/init-add-node-modules-path ()
|
||||
(use-package add-node-modules-path :defer t))
|
Loading…
Reference in a new issue