Last active
September 2, 2021 14:11
-
-
Save tkuriyama/9dc372fdf7069744e3def37a6c8f8087 to your computer and use it in GitHub Desktop.
initial setup for js2 mode in emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-package js2-mode | |
:ensure t | |
:mode | |
(("\\.m?js\\'" . js2-mode)) | |
:config | |
(add-hook 'js2-mode-hook | |
(lambda () (interactive) (column-marker-1 80))) | |
;; Better imenu | |
(setq js2-mode-show-parse-errors nil) | |
(setq js2-mode-show-strict-warnings nil) | |
(add-hook 'js2-mode-hook | |
#'js2-imenu-extras-mode) | |
(add-hook 'js2-mode-hook | |
(defun my-js2-mode-setup () | |
(flycheck-mode t) | |
(when (executable-find "eslint") | |
(flycheck-select-checker 'javascript-eslint)))) | |
:custom | |
;; (js2-global-externs '("customElements")) | |
(js2-include-node-externs t) | |
(js2-highlight-level 3) | |
(js2r-prefer-let-over-var t) | |
(js2r-prefered-quote-type 2) | |
) | |
(use-package js2-refactor | |
:ensure t | |
:config | |
(add-hook 'js2-mode-hook #'js2-refactor-mode) | |
(js2r-add-keybindings-with-prefix "C-c C-r") | |
(define-key js2-mode-map (kbd "C-k") #'js2r-kill) | |
) | |
(use-package xref-js2 | |
:ensure t | |
:config | |
;; js-mode (which js2 is based on) binds "M-." which conflicts with xref, so | |
;; unbind it. | |
(define-key js-mode-map (kbd "M-.") nil) | |
(add-hook 'js2-mode-hook | |
(lambda () | |
(add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t))) | |
) | |
;; (use-package web-mode | |
;; :ensure t | |
;; :mode | |
;; (("\\.jsx$" . web-mode)) | |
;; ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment