2019-02-25 05:02:21 +01:00
|
|
|
|
;;; oni-js.el --- JavaScript configuration -*- lexical-binding: t; -*-
|
2019-02-06 09:27:28 +01:00
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2019 Tom Willemse
|
|
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
|
;; Keywords: local
|
2022-12-04 16:37:16 +01:00
|
|
|
|
;; Version: 2022.1129.232529
|
|
|
|
|
;; Package-Requires: (oni-company js2-mode js2-refactor oni-flycheck fic-mode rjsx-mode)
|
2019-02-06 09:27:28 +01:00
|
|
|
|
|
|
|
|
|
;; 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:
|
|
|
|
|
|
2019-02-25 05:02:21 +01:00
|
|
|
|
;; JavaScript configuration.
|
2019-02-06 09:27:28 +01:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'company)
|
2019-02-25 05:02:21 +01:00
|
|
|
|
(require 'js)
|
2019-02-06 09:27:28 +01:00
|
|
|
|
(require 'js2-mode)
|
|
|
|
|
(require 'js2-refactor)
|
|
|
|
|
(require 'whitespace)
|
|
|
|
|
|
2019-02-19 09:13:51 +01:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'grep))
|
|
|
|
|
|
2019-02-25 05:02:21 +01:00
|
|
|
|
(defun oni-js-whitespace-mode ()
|
2019-02-06 09:27:28 +01:00
|
|
|
|
"Enable whitespace mode with only tabs showing."
|
|
|
|
|
(setq-local whitespace-style '(face tabs))
|
|
|
|
|
(whitespace-mode))
|
|
|
|
|
|
2019-12-11 08:16:15 +01:00
|
|
|
|
(defun oni-js--auto-fill-mode ()
|
|
|
|
|
"Enable ‘auto-fill-mode’ only for comments."
|
|
|
|
|
(setq-local comment-auto-fill-only-comments t)
|
|
|
|
|
(auto-fill-mode))
|
|
|
|
|
|
2019-02-25 05:02:21 +01:00
|
|
|
|
(setq js-enabled-frameworks '(javascript))
|
|
|
|
|
|
2019-02-06 09:27:28 +01:00
|
|
|
|
(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)
|
|
|
|
|
|
2019-02-25 05:02:21 +01:00
|
|
|
|
(add-hook 'js-mode-hook 'electric-pair-local-mode)
|
|
|
|
|
(add-hook 'js-mode-hook 'electric-indent-local-mode)
|
2019-12-11 08:16:15 +01:00
|
|
|
|
(add-hook 'js-mode-hook 'oni-js--auto-fill-mode)
|
2019-02-25 05:02:21 +01:00
|
|
|
|
|
2019-02-06 09:27:28 +01:00
|
|
|
|
(add-hook 'js2-mode-hook 'company-mode)
|
2021-06-23 07:19:53 +02:00
|
|
|
|
(add-hook 'js2-mode-hook 'display-fill-column-indicator-mode)
|
2019-02-06 09:27:28 +01:00
|
|
|
|
(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)
|
2021-06-23 07:19:53 +02:00
|
|
|
|
(add-hook 'js2-mode-hook 'oni-js--auto-fill-mode)
|
2019-02-25 05:02:21 +01:00
|
|
|
|
(add-hook 'js2-mode-hook 'oni-js-whitespace-mode)
|
2019-02-06 09:27:28 +01:00
|
|
|
|
(add-hook 'js2-mode-hook 'subword-mode)
|
2020-09-07 23:45:10 +02:00
|
|
|
|
|
2019-02-06 09:27:28 +01:00
|
|
|
|
(js2r-add-keybindings-with-prefix "C-c r")
|
|
|
|
|
|
2019-02-19 09:13:51 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
|
|
|
|
|
|
2019-03-03 19:35:18 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . rjsx-mode))
|
|
|
|
|
|
2019-02-19 09:13:51 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(with-eval-after-load 'grep
|
|
|
|
|
(add-to-list 'grep-files-aliases '("js" . "*.js *.jsx *.json")))
|
2019-02-06 09:27:28 +01:00
|
|
|
|
|
2019-02-25 05:02:21 +01:00
|
|
|
|
(provide 'oni-js)
|
|
|
|
|
;;; oni-js.el ends here
|