2018-05-14 04:46:45 +00:00
|
|
|
;;; packages.el --- JSON Layer packages File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2018-05-14 04:46:45 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00: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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-05-14 04:46:45 +00:00
|
|
|
|
2021-05-11 19:24:52 +00:00
|
|
|
(defconst json-packages
|
|
|
|
'(
|
|
|
|
company
|
|
|
|
add-node-modules-path
|
|
|
|
flycheck
|
|
|
|
json-mode
|
|
|
|
json-navigator
|
|
|
|
json-reformat
|
|
|
|
json-snatcher
|
|
|
|
prettier-js
|
|
|
|
web-beautify))
|
2020-06-23 20:19:51 +00:00
|
|
|
|
|
|
|
(defun json/post-init-company ()
|
|
|
|
(spacemacs//json-setup-company))
|
2018-05-14 04:46:45 +00:00
|
|
|
|
|
|
|
(defun json/post-init-add-node-modules-path ()
|
2018-05-15 00:49:59 +00:00
|
|
|
(add-hook 'json-mode-hook #'add-node-modules-path))
|
2018-05-14 04:46:45 +00:00
|
|
|
|
|
|
|
(defun json/post-init-flycheck ()
|
|
|
|
(spacemacs/enable-flycheck 'json-mode))
|
|
|
|
|
|
|
|
(defun json/init-json-mode ()
|
|
|
|
(use-package json-mode
|
2020-06-23 20:19:51 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
2021-03-18 04:25:03 +00:00
|
|
|
(unless (eq json-backend 'lsp)
|
2020-06-23 20:19:51 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'json-mode "mT" "toggle")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'json-mode "mh" "help")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'json-mode "m=" "format"))
|
|
|
|
(add-hook 'json-mode-hook #'spacemacs//json-setup-backend))))
|
2018-05-14 04:46:45 +00:00
|
|
|
|
|
|
|
(defun json/init-json-navigator ()
|
|
|
|
(use-package json-navigator
|
|
|
|
:defer t
|
2021-05-12 05:13:29 +00:00
|
|
|
:init (spacemacs/set-leader-keys-for-major-mode 'json-mode
|
|
|
|
"Th" 'spacemacs/json-navigator-dwim)
|
|
|
|
:config (evilified-state-evilify-map json-navigator-mode-map
|
|
|
|
:mode json-navigator-mode)))
|
2018-05-14 04:46:45 +00:00
|
|
|
|
|
|
|
(defun json/init-json-reformat ()
|
|
|
|
(use-package json-reformat
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'json-mode
|
2019-01-21 07:12:05 +00:00
|
|
|
"==" 'spacemacs/json-reformat-dwim)))
|
2018-05-14 04:46:45 +00:00
|
|
|
|
|
|
|
(defun json/init-json-snatcher ()
|
|
|
|
(use-package json-snatcher
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'json-mode
|
|
|
|
"hp" 'jsons-print-path)))
|
2018-05-18 05:15:03 +00:00
|
|
|
|
2018-06-19 06:25:33 +00:00
|
|
|
(defun json/pre-init-prettier-js ()
|
2018-09-22 20:08:44 +00:00
|
|
|
(when (eq json-fmt-tool 'prettier)
|
2018-11-07 06:30:42 +00:00
|
|
|
(add-to-list 'spacemacs--prettier-modes 'json-mode)
|
2019-09-05 03:44:13 +00:00
|
|
|
(add-hook 'json-mode-hook #'spacemacs/json-setup-prettier)
|
|
|
|
(when (eq json-fmt-on-save t)
|
|
|
|
(add-hook 'json-mode-hook 'prettier-js-mode))))
|
2018-06-19 06:25:33 +00:00
|
|
|
|
2018-05-19 05:53:33 +00:00
|
|
|
(defun json/pre-init-web-beautify ()
|
2018-11-07 06:30:42 +00:00
|
|
|
(when (eq json-fmt-tool 'web-beautify)
|
|
|
|
(add-to-list 'spacemacs--web-beautify-modes
|
2019-09-05 03:44:13 +00:00
|
|
|
(cons 'json-mode 'web-beautify-js))
|
|
|
|
(when (eq json-fmt-on-save t)
|
|
|
|
(add-hook 'json-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(add-hook 'before-save-hook 'web-beautify-js-buffer t t))))))
|