summaryrefslogtreecommitdiffstats
path: root/syntax/graphql.vim
blob: 8a7f07c5996b8a45d8d0c2c6b930529fd27592b3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1
  
" Vim syntax file
" Language: GraphQL
" Maintainer: Jon Parise <jon@indelible.org>

if exists('b:current_syntax')
    finish
endif

syn match graphqlComment    "#.*$" contains=@Spell

syn match graphqlOperator   "="
syn match graphqlOperator   "!"
syn match graphqlOperator   "|"
syn match graphqlOperator   "\M..."

syn keyword graphqlBoolean  true false
syn keyword graphqlNull     null
syn match   graphqlNumber   "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>"
syn region  graphqlString	start=+"+  skip=+\\\\\|\\"+  end=+"\|$+

syn keyword graphqlKeyword on nextgroup=graphqlType skipwhite

syn keyword graphqlStructure enum scalar type union nextgroup=graphqlType skipwhite
syn keyword graphqlStructure input interface subscription nextgroup=graphqlType skipwhite
syn keyword graphqlStructure implements nextgroup=graphqlType skipwhite
syn keyword graphqlStructure query mutation fragment nextgroup=graphqlIdentifier skipwhite
syn keyword graphqlStructure directive nextgroup=graphqlDirective skipwhite
syn keyword graphqlStructure extend nextgroup=graphqlStructure skipwhite

syn match graphqlDirective  "\<@\h\w*\>"   display
syn match graphqlVariable   "\<\$\h\w*\>"  display

syn match graphqlIdentifier "\<\h\w*\>"    display contained
syn match graphqlType       "\<_*\u\w*\>"  display contained
syn match graphqlConstant   "\<[A-Z_]\+\>" display contained

syn keyword graphqlMetaFields __schema __type __typename

syn region  graphqlFold matchgroup=graphqlBraces start="{" end=/}\(\_s\+\ze\("\|{\)\)\@!/ transparent fold contains=ALLBUT,graphqlStructure
syn region  graphqlList matchgroup=graphqlBraces start="\[" end=/]\(\_s\+\ze"\)\@!/ transparent contains=ALLBUT,graphqlDirective,graphqlStructure

hi def link graphqlComment          Comment
hi def link graphqlOperator         Operator

hi def link graphqlBraces           Delimiter

hi def link graphqlBoolean          Boolean
hi def link graphqlNull             Keyword
hi def link graphqlNumber           Number
hi def link graphqlString           String

hi def link graphqlConstant         Constant
hi def link graphqlDirective        PreProc
hi def link graphqlIdentifier       Identifier
hi def link graphqlMetaFields       Special
hi def link graphqlKeyword          Keyword
hi def link graphqlStructure        Structure
hi def link graphqlType             Type
hi def link graphqlVariable         Identifier

syn sync minlines=500

let b:current_syntax = 'graphql'

endif