branch: elpa/graphql-mode
commit 1210279ff4a5e0c6f074f2f6b4c534c69356a4ee
Author: Tim Shiu <[email protected]>
Commit: David Vázquez Púa <[email protected]>
Add keywords only completion
---
graphql-mode.el | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/graphql-mode.el b/graphql-mode.el
index 9d57d0918c..5b7d65a635 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -240,6 +240,19 @@ VARIABLES list of variables for query operation"
(when (< position indent-pos)
(goto-char indent-pos))))
+(defvar graphql-keywords
+ '("type" "input" "interface" "fragment" "query" "enum" "mutation"
"subscription"
+ "Int" "Float" "String" "Boolean" "ID"
+ "true" "false" "null"))
+
+(defun graphql-completion-at-point ()
+ "Return the list of candidates for completion.
+This is the function to be used for the hook `completion-at-point-functions'."
+ (let* ((bds (bounds-of-thing-at-point 'symbol))
+ (start (car bds))
+ (end (cdr bds)))
+ (list start end graphql-keywords . nil)))
+
(defvar graphql-definition-regex
(concat "\\(" (regexp-opt '("type" "input" "interface" "fragment" "query"
"mutation" "subscription" "enum")) "\\)"
@@ -332,8 +345,8 @@ VARIABLES list of variables for query operation"
nil
nil
nil))
- (setq imenu-generic-expression
- `((nil ,graphql-definition-regex 2))))
+ (setq imenu-generic-expression `((nil ,graphql-definition-regex 2)))
+ (add-hook 'completion-at-point-functions 'graphql-completion-at-point nil
'local))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.graphql\\'" . graphql-mode))