Tom Willemse
4d0a1c884d
Fall back to ‘fci-mode’ if the function ‘display-fill-column-indicator-mode’ doesn’t exist.
91 lines
2.8 KiB
EmacsLisp
91 lines
2.8 KiB
EmacsLisp
;;; oni-js.el --- JavaScript configuration -*- lexical-binding: t; -*-
|
||
|
||
;; Copyright (C) 2019 Tom Willemse
|
||
|
||
;; Author: Tom Willemse <tom@ryuslash.org>
|
||
;; Keywords: local
|
||
;; Version: 2020.0907.143324
|
||
;; Package-Requires: (oni-company js2-mode js2-refactor oni-fci oni-flycheck tern company-tern fic-mode rjsx-mode)
|
||
|
||
;; This program is free software; you can redistribute it and/or modify
|
||
;; it under the terms of the GNU General Public License as published by
|
||
;; the Free Software Foundation, either version 3 of the License, or
|
||
;; (at your option) any later version.
|
||
|
||
;; This program is distributed in the hope that it will be useful,
|
||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
;; GNU General Public License for more details.
|
||
|
||
;; You should have received a copy of the GNU General Public License
|
||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
||
;;; Commentary:
|
||
|
||
;; JavaScript configuration.
|
||
|
||
;;; Code:
|
||
|
||
(require 'company)
|
||
(require 'js)
|
||
(require 'js2-mode)
|
||
(require 'js2-refactor)
|
||
(require 'whitespace)
|
||
|
||
(eval-when-compile
|
||
(require 'grep))
|
||
|
||
(defun oni-js-whitespace-mode ()
|
||
"Enable whitespace mode with only tabs showing."
|
||
(setq-local whitespace-style '(face tabs))
|
||
(whitespace-mode))
|
||
|
||
(defun oni-js--auto-fill-mode ()
|
||
"Enable ‘auto-fill-mode’ only for comments."
|
||
(setq-local comment-auto-fill-only-comments t)
|
||
(auto-fill-mode))
|
||
|
||
(setq js-enabled-frameworks '(javascript))
|
||
|
||
(setq js2-include-node-externs t)
|
||
(setq js2-strict-trailing-comma-warning nil)
|
||
(setq js2-strict-missing-semi-warning nil)
|
||
(setq js2-basic-offset 2)
|
||
|
||
(add-hook 'js-mode-hook 'electric-pair-local-mode)
|
||
(add-hook 'js-mode-hook 'electric-indent-local-mode)
|
||
(add-hook 'js-mode-hook 'oni-js--auto-fill-mode)
|
||
|
||
(add-hook 'js2-mode-hook 'company-mode)
|
||
(add-hook 'js2-mode-hook 'electric-pair-local-mode)
|
||
(add-hook 'js2-mode-hook 'fic-mode)
|
||
(add-hook 'js2-mode-hook 'flycheck-mode)
|
||
(add-hook 'js2-mode-hook 'js2-refactor-mode)
|
||
(add-hook 'js2-mode-hook 'oni-js-whitespace-mode)
|
||
(add-hook 'js2-mode-hook 'subword-mode)
|
||
(add-hook 'js2-mode-hook 'tern-mode)
|
||
(add-hook 'js2-mode-hook 'oni-js--auto-fill-mode)
|
||
|
||
(add-hook 'js2-mode-hook
|
||
(if (fboundp 'display-fill-column-indicator-mode)
|
||
'display-fill-column-indicator-mode
|
||
'fci-mode))
|
||
|
||
(js2r-add-keybindings-with-prefix "C-c r")
|
||
|
||
(add-to-list 'company-backends 'company-tern)
|
||
|
||
;;;###autoload(with-eval-after-load 'js2-mode (require 'oni-js))
|
||
|
||
;;;###autoload
|
||
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
|
||
|
||
;;;###autoload
|
||
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . rjsx-mode))
|
||
|
||
;;;###autoload
|
||
(with-eval-after-load 'grep
|
||
(add-to-list 'grep-files-aliases '("js" . "*.js *.jsx *.json")))
|
||
|
||
(provide 'oni-js)
|
||
;;; oni-js.el ends here
|