branch: elpa/graphql-mode
commit 7d954d00450d7573c5c42f2ef452a01913dc1cd5
Author: David Vazquez Pua <[email protected]>
Commit: David Vazquez Pua <[email protected]>

    Fix font lock to highlight whole symbols, not just words
    
    The \w+ regex matches word constituents, but for example, _ is a
    symbol consistuent but not word constituent.
    
    Replace it with the regex (\_<.*?\_>)
    
    Fix #8
---
 graphql-mode.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/graphql-mode.el b/graphql-mode.el
index e56a7bf16e..15da3620af 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -122,6 +122,7 @@ response from the server."
   (let ((st (make-syntax-table)))
     (modify-syntax-entry ?\# "<" st)
     (modify-syntax-entry ?\n ">" st)
+    (modify-syntax-entry ?\$ "'" st)
     st))
 
 
@@ -144,7 +145,7 @@ response from the server."
 
 (defvar graphql-definition-regex
   (concat "\\(" (regexp-opt '("type" "input" "interface" "fragment" "query" 
"enum")) "\\)"
-          "[[:space:]]+\\(\\w+\\)"))
+          "[[:space:]]+\\(\\_<.+?\\_>\\)"))
 
 (defvar graphql-builtin-types
   '("Int" "Float" "String" "Boolean" "ID"))
@@ -186,10 +187,10 @@ response from the server."
 (defvar graphql-font-lock-keywords
   `(
     ;; Type definition
-    ("\\(type\\)[[:space:]]+\\(\\w+\\)"
+    ("\\(type\\)[[:space:]]+\\(\\_<.+?\\_>\\)"
      (1 font-lock-keyword-face)
      (2 font-lock-function-name-face)
-     ("[[:space:]]+\\(implements\\)\\(?:[[:space:]]+\\(\\w+\\)\\)?"
+     ("[[:space:]]+\\(implements\\)\\(?:[[:space:]]+\\(\\_<.+?\\_>\\)\\)?"
       nil nil
       (1 font-lock-keyword-face)
       (2 font-lock-function-name-face)))

Reply via email to