[new layer][graphql] add graphql layer
It builds around graphql-mode - Syntax highlight and graphql calls with graphql-mode - Autocomplete with comapy-dabbrev - Format buffer with prettier - Go to definition with ahs
This commit is contained in:
parent
0046448c81
commit
dd2217b50e
|
@ -0,0 +1,38 @@
|
|||
#+TITLE: graphql layer
|
||||
#+TAGS: layer|language
|
||||
|
||||
[[file:img/graphql.png]]
|
||||
|
||||
* Table of Contents :TOC_4_gh:noexport:
|
||||
- [[#description][Description]]
|
||||
- [[#features][Features:]]
|
||||
- [[#install][Install]]
|
||||
- [[#key-bindings][Key bindings]]
|
||||
|
||||
* Description
|
||||
This layer adds support for graphql file. It builds around [[https://github.com/davazp/graphql-mode][graphql-mode]]. Please
|
||||
check its site for extra info.
|
||||
|
||||
** Features:
|
||||
- Syntax highlight and graphql calls with =graphql-mode=
|
||||
- Autocomplete with =comapy-dabbrev=
|
||||
- Format buffer with =prettier=
|
||||
- Go to definition with =ahs=
|
||||
|
||||
* Install
|
||||
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
||||
add =graphql= to the existing =dotspacemacs-configuration-layers= list in this
|
||||
file.
|
||||
|
||||
If you want to format graphql buffers you need to enable =prettier= layer also.
|
||||
|
||||
* Key bindings
|
||||
|
||||
| Key Binding | Description |
|
||||
|-------------+-------------------------------|
|
||||
| ~SPC m = =~ | graphql-edit-headers |
|
||||
| ~SPC m e~ | graphql-select-endpoint |
|
||||
| ~SPC m g G~ | jump to definition new window |
|
||||
| ~SPC m g g~ | jump to definition |
|
||||
| ~SPC m h~ | graphql-edit-headers |
|
||||
| ~SPC m s~ | graphql-send-query |
|
|
@ -0,0 +1,12 @@
|
|||
;;; config.el --- vue layer config file for Spacemacs. -*- lexical-binding: t -*-
|
||||
;;
|
||||
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Thanh Vuong <thanhvg@gmail.com>
|
||||
;; URL: https://github.com/thanhvg
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(spacemacs|define-jump-handlers graphql-mode)
|
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
|
@ -0,0 +1,56 @@
|
|||
;;; packages.el --- graphql layer packages file for Spacemacs.
|
||||
;;
|
||||
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Thanh Vuong <thanh@gmail.com>
|
||||
;; URL: https://github.com/thanhvg
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; See the Spacemacs documentation and FAQs for instructions on how to implement
|
||||
;; a new layer:
|
||||
;;
|
||||
;; SPC h SPC layers RET
|
||||
;;
|
||||
;;
|
||||
;; Briefly, each package to be installed or configured by this layer should be
|
||||
;; added to `graphql-packages'. Then, for each package PACKAGE:
|
||||
;;
|
||||
;; - If PACKAGE is not referenced by any other Spacemacs layer, define a
|
||||
;; function `graphql/init-PACKAGE' to load and initialize the package.
|
||||
|
||||
;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so
|
||||
;; define the functions `graphql/pre-init-PACKAGE' and/or
|
||||
;; `graphql/post-init-PACKAGE' to customize the package as it is loaded.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defconst graphql-packages
|
||||
'(company
|
||||
prettier-js
|
||||
graphql-mode))
|
||||
|
||||
(defun graphql/init-graphql-mode ()
|
||||
(use-package graphql-mode
|
||||
:defer t
|
||||
:init
|
||||
(add-to-list 'spacemacs-jump-handlers-graphql-mode 'ahs-backward-definition))
|
||||
(when (configuration-layer/layer-used-p 'prettier)
|
||||
(spacemacs/declare-prefix-for-mode 'graphql-mode "m=" "format"))
|
||||
(spacemacs/declare-prefix-for-mode 'graphql-mode "mg" "goto")
|
||||
(spacemacs/set-leader-keys-for-major-mode 'graphql-mode
|
||||
"s" 'graphql-send-query
|
||||
"e" 'graphql-select-endpoint
|
||||
"h" 'graphql-edit-headers))
|
||||
|
||||
(defun graphql/post-init-company ()
|
||||
(spacemacs|add-company-backends
|
||||
:backends company-dabbrev
|
||||
:modes graphql-mode))
|
||||
|
||||
(defun graphql/pre-init-prettier-js ()
|
||||
(add-to-list 'spacemacs--prettier-modes 'graphql-mode))
|
Loading…
Reference in New Issue