feat(graphql): add treesit support

This commit is contained in:
Henrik Lissner
2025-08-28 14:17:38 +02:00
parent 64b4e565c3
commit f782b79797
4 changed files with 41 additions and 13 deletions

View File

@@ -1,22 +1,18 @@
;;; lang/graphql/config.el -*- lexical-binding: t; -*-
(after! graphql-mode
(defface nerd-icons-rhodamine
'((t (:foreground "#E10098")))
"Face for GraphQL icon."
:group 'nerd-icons-faces)
;;
;;; Packages
(defun +graphql-common-config (mode)
(if (modulep! +lsp)
(add-hook 'graphql-mode-local-vars-hook #'lsp! 'append)
(set-company-backend! 'graphql-mode 'company-graphql))
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append)
(set-company-backend! mode 'company-graphql))
(add-hook 'graphql-mode-hook #'rainbow-delimiters-mode)
(set-docsets! 'graphql-mode :add "GraphQL Specification")
(set-electric! 'graphql-mode
(set-docsets! mode :add "GraphQL Specification")
(set-electric! mode
:chars '(?\} ?\))
:words '("or" "and"))
(set-ligatures! 'graphql-mode
(set-ligatures! mode
:null "null"
:true "true" :false "false"
:int "Int" :str "String"
@@ -26,5 +22,26 @@
:not "not"
:and "and" :or "or"))
(after! graphql-mode
(defface nerd-icons-rhodamine
'((t (:foreground "#E10098")))
"Face for GraphQL icon."
:group 'nerd-icons-faces)
(add-hook 'graphql-mode-hook #'rainbow-delimiters-mode)
(+graphql-common-config 'graphql-mode))
(use-package! graphql-ts-mode
:when (modulep! +tree-sitter)
:when (fboundp 'treesit-available-p)
:defer t
:init
(set-tree-sitter! 'graphql-mode 'graphql-ts-mode
'((graphql :url "https://github.com/bkegley/tree-sitter-graphql")))
:config
(+graphql-common-config 'graphql-ts-mode))
(use-package! graphql-doc
:after graphql-mode)