From b6220b1d6f4cd30e3c4c28b0f2243f831545c7ce Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 24 Feb 2019 20:02:21 -0800 Subject: Unify JavaScript configuration in oni-js --- oni-js.el | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ oni-js2-mode.el | 71 ---------------------------------------------------- 2 files changed, 77 insertions(+), 71 deletions(-) create mode 100644 oni-js.el delete mode 100644 oni-js2-mode.el diff --git a/oni-js.el b/oni-js.el new file mode 100644 index 0000000..f6e6ff6 --- /dev/null +++ b/oni-js.el @@ -0,0 +1,77 @@ +;;; oni-js.el --- JavaScript configuration -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Tom Willemse + +;; Author: Tom Willemse +;; Keywords: local +;; Version: 20190224201011 +;; Package-Requires: (oni-company js2-mode js2-refactor flycheck fill-column-indicator tern company-tern fic-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 . + +;;; 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)) + +(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 'js2-mode-hook 'company-mode) +(add-hook 'js2-mode-hook 'electric-pair-local-mode) +(add-hook 'js2-mode-hook 'fci-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) + +(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 +(with-eval-after-load 'grep + (add-to-list 'grep-files-aliases '("js" . "*.js *.jsx *.json"))) + +(provide 'oni-js) +;;; oni-js.el ends here diff --git a/oni-js2-mode.el b/oni-js2-mode.el deleted file mode 100644 index 7932943..0000000 --- a/oni-js2-mode.el +++ /dev/null @@ -1,71 +0,0 @@ -;;; oni-js2-mode.el --- js2-mode configuration -*- lexical-binding: t; -*- - -;; Copyright (C) 2019 Tom Willemse - -;; Author: Tom Willemse -;; Keywords: local -;; Version: 20190219001218 -;; Package-Requires: (oni-company js2-mode js2-refactor flycheck fill-column-indicator tern company-tern fic-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 . - -;;; Commentary: - -;; My `js2-mode' configuration. - -;;; Code: - -(require 'company) -(require 'js2-mode) -(require 'js2-refactor) -(require 'whitespace) - -(eval-when-compile - (require 'grep)) - -(defun oni-js2-mode-whitespace-mode () - "Enable whitespace mode with only tabs showing." - (setq-local whitespace-style '(face tabs)) - (whitespace-mode)) - -(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 'js2-mode-hook 'company-mode) -(add-hook 'js2-mode-hook 'electric-pair-local-mode) -(add-hook 'js2-mode-hook 'fci-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-js2-mode-whitespace-mode) -(add-hook 'js2-mode-hook 'subword-mode) -(add-hook 'js2-mode-hook 'tern-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-js2-mode)) - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) - -;;;###autoload -(with-eval-after-load 'grep - (add-to-list 'grep-files-aliases '("js" . "*.js *.jsx *.json"))) - -(provide 'oni-js2-mode) -;;; oni-js2-mode.el ends here -- cgit v1.3-2-g0d8e