1
0
Fork
You've already forked graphql-ts-mode
0
GraphQL major mode for Emacs based on tree-sitter
  • Emacs Lisp 100%
Find a file
2024年01月05日 13:36:34 +01:00
.gitignore Slightly improve docs and code style 2023年09月09日 23:04:10 +02:00
graphql-ts-mode.el Add .graphqls to auto-mode-alist 2024年01月05日 13:36:34 +01:00
LICENSE Initial commit 2023年09月09日 20:20:23 +02:00
README.md Add MELPA to the README 2023年09月12日 22:50:51 +02:00

graphql-ts-mode

MELPA

This is a major mode for editing GraphQL documents based on the built in support for tree-sitter in Emacs.

Installation

Requires Emacs 29.1 or later with tree-sitter support. This was developed for the grammar available here.

The installation snippets below add configuration to automatically install the grammar using treesit-install-language-grammar. This requires a working C compiler. Install the grammar before opening a GraphQL file to avoid errors.

From MELPA

This package is available from MELPA.

(use-package graphql-ts-mode
 :ensure t
 :mode ("\\.graphql\\'" "\\.gql\\'")
 :init
 (with-eval-after-load 'treesit
 (add-to-list 'treesit-language-source-alist
 '(graphql "https://github.com/bkegley/tree-sitter-graphql"))))

From source

Clone this repository to ~/.emacs.d/lisp/graphql-ts-mode/ or another path, then configure it like this:

(use-package graphql-ts-mode
 :ensure nil
 :load-path "lisp/graphql-ts-mode/"
 :mode ("\\.graphql\\'" "\\.gql\\'")
 :init
 (with-eval-after-load 'treesit
 (add-to-list 'treesit-language-source-alist
 '(graphql "https://github.com/bkegley/tree-sitter-graphql"))))

Comparison to graphql-mode

There is an existing major mode for GraphQL that does not require tree-sitter, called graphql-mode.

The major differences between graphql-ts-mode and graphql-mode are:

  • graphql-mode has features to send actual queries, graphql-ts-mode does not
  • graphql-ts-mode should perform better on large files
  • graphql-ts-mode has more extensive syntax highlighting