This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/json/packages.el

95 lines
3 KiB
EmacsLisp
Raw Normal View History

;;; packages.el --- JSON Layer packages File for Spacemacs
;;
2021-03-22 20:11:29 +00:00
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;; 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/>.
(setq json-packages
'(
2020-06-23 20:19:51 +00:00
company
add-node-modules-path
flycheck
json-mode
json-navigator
json-reformat
json-snatcher
prettier-js
2020-06-23 20:19:51 +00:00
web-beautify))
(defun json/post-init-company ()
(spacemacs//json-setup-company))
(defun json/post-init-add-node-modules-path ()
(add-hook 'json-mode-hook #'add-node-modules-path))
(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
(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))))
(defun json/init-json-navigator ()
(use-package json-navigator
:defer t
:init
(progn
(evilified-state-evilify-map tabulated-list-mode-map
:mode special-mode)
(spacemacs/set-leader-keys-for-major-mode 'json-mode
2020-06-23 20:19:51 +00:00
"Th" 'spacemacs/json-navigator-dwim))))
(defun json/init-json-reformat ()
(use-package json-reformat
:defer t
:init
(spacemacs/set-leader-keys-for-major-mode 'json-mode
"==" 'spacemacs/json-reformat-dwim)))
(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)))
(defun json/pre-init-prettier-js ()
(when (eq json-fmt-tool 'prettier)
(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))))
(defun json/pre-init-web-beautify ()
(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))))))