branch: elpa/graphql-mode
commit 096df5b167c8b62e45ffa69d5b0a15d28a428e10
Author: David Vazquez Pua <[email protected]>
Commit: David Vazquez Pua <[email protected]>
Basic line indentation
---
graphql.el | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/graphql.el b/graphql.el
index 960383f1a7..7429d78cad 100644
--- a/graphql.el
+++ b/graphql.el
@@ -31,8 +31,23 @@
(modify-syntax-entry ?\" "\"" st)
(modify-syntax-entry ?\# "<" st)
(modify-syntax-entry ?\n ">" st)
+ (modify-syntax-entry ?\( "()" st)
+ (modify-syntax-entry ?\) ")(" st)
+ (modify-syntax-entry ?\{ "(}" st)
+ (modify-syntax-entry ?\} "){" st)
st))
+
+(defun graphql-indent-line ()
+ (let ((position (point))
+ (indent-pos))
+ (save-excursion
+ (indent-line-to (* 2 (car (syntax-ppss (point-at-bol)))))
+ (setq indent-pos (point)))
+ (when (< position indent-pos)
+ (goto-char indent-pos))))
+
+
(defvar graphql-font-lock-keywords
`(
;; Definitions
@@ -55,6 +70,7 @@
""
(setq-local comment-start "# ")
(setq-local comment-start-skip "#+[\t ]*")
+ (setq-local indent-line-function 'graphql-indent-line)
(setq font-lock-defaults
(list 'graphql-font-lock-keywords
nil