aboutsummaryrefslogtreecommitdiffstats
path: root/modules/init-js-two.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/init-js-two.el')
-rw-r--r--modules/init-js-two.el50
1 files changed, 26 insertions, 24 deletions
diff --git a/modules/init-js-two.el b/modules/init-js-two.el
index 2e88d45..7162eb1 100644
--- a/modules/init-js-two.el
+++ b/modules/init-js-two.el
@@ -8,23 +8,19 @@
;; https://github.com/mooz/js2-mode
(use-package js2-mode
:ensure t
- :defer 20
- :hook ((js2-mode . (lambda ()
- (company-mode))))
- :mode (("\\.js\\'" . js2-mode))
+ :pin "MELPA"
+ :mode ("\\.js'\\'" . js2-mode)
+ :hook (js2-mode . company-mode)
:custom
(js2-include-node-externs t)
(js2-global-externs '("customElements"))
(js2-highlight-level 3)
(js2r-prefer-let-over-var t)
- (js2r-prefered-quote-type 2)
+ (js2r-preferred-quote-type 2)
(js-indent-align-list-continuation t)
- (global-auto-highlight-symbol-mode t)
- ;; use eslint_d insetad of eslint for faster linting
- (flycheck-javascript-eslint-executable "eslint_d")
:config
+ (setq-default flycheck-javascript-eslint-executable "eslint_d")
(setq js-indent-level 2)
- ;; patch in basic private field support
(advice-add #'js2-identifier-start-p
:after-until
(lambda (c) (eq c ?#))))
@@ -34,12 +30,13 @@
(use-package js2-refactor
:pin "MELPA"
:after js2-mode
- :bind
- (:map js2-mode-map
- ("C-k" . js2r-kill)
- ("C-c h r" . js2-refactor-hydra/body))
- :hook ((js2-mode . js2-refactor-mode))
- :config (js2r-add-keybindings-with-prefix "C-c C-r")
+ :hook (js2-mode . js2-refactor-mode)
+ :config
+ ;; Add keybindings for js2-refactor with prefix "C-c C-r".
+ (js2r-add-keybindings-with-prefix "C-c C-r")
+ ;; Assign keybindings to kill an element in js2 and to open the js2-refactor's hydra menu.
+ (bind-key "C-k" 'js2r-kill js2-mode-map)
+ (bind-key "C-c h r" 'js2-refactor-hydra/body js2-mode-map)
(defhydra js2-refactor-hydra (:color blue :hint nil)
"
@@ -82,21 +79,26 @@
;; json-mode: Major mode for editing JSON files with emacs
;; https://github.com/joshwnj/json-mode
-(use-package prettier-js
- :pin "MELPA")
(use-package json-mode
- :pin "MELPA"
:ensure t
- :defer 20
+ :pin "MELPA"
+ :mode ("\\.json\\'" "\\.jsonld\\'")
:custom
(json-reformat:indent-width 2)
(json-reformat:pretty-string? t)
(js-indent-level 2)
- :mode "\\.js\\(?:on\\|[hl]int\\(rc\\)?\\)\\'"
- :hook ((json-mode . prettier-js-mode))
- :bind (:package json-mode-map
- :map json-mode-map
- ("C-c <tab>" . json-mode-beautify)))
+ :hook
+ (json-mode . (lambda ()
+ (add-hook 'before-save-hook 'json-mode-before-save nil t)
+ (prettier-js-mode)))
+ :bind
+ (:map json-mode-map
+ ("C-c <tab>" . json-mode-beautify)))
+
+(use-package prettier-js
+ :pin "MELPA"
+ :hook
+ ((js-mode typescript-mode css-mode scss-mode less-mode web-mode json-mode) . prettier-js-mode))
;; eslintd-fix: Emacs minor-mode to automatically fix javascript with eslint_d.
;; https://github.com/aaronjensen/eslintd-fix/tree/master