vim-polyglot/syntax/graphql.vim

68 lines
2.5 KiB
VimL
Raw Normal View History

2017-05-17 05:17:16 -04:00
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1
" Vim syntax file
" Language: GraphQL
" Maintainer: Jon Parise <jon@indelible.org>
2017-09-27 13:57:29 -04:00
if exists('b:current_syntax')
2017-05-17 05:17:16 -04:00
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=+"\|$+
2017-09-27 13:57:29 -04:00
syn keyword graphqlKeyword on nextgroup=graphqlType skipwhite
2017-05-17 05:17:16 -04:00
syn keyword graphqlStructure enum scalar type union nextgroup=graphqlType skipwhite
syn keyword graphqlStructure input interface subscription nextgroup=graphqlType skipwhite
2017-09-27 13:57:29 -04:00
syn keyword graphqlStructure implements nextgroup=graphqlType skipwhite
2017-05-17 05:17:16 -04:00
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
2017-09-27 13:57:29 -04:00
hi def link graphqlKeyword Keyword
2017-05-17 05:17:16 -04:00
hi def link graphqlStructure Structure
hi def link graphqlType Type
hi def link graphqlVariable Identifier
syn sync minlines=500
2017-09-27 13:57:29 -04:00
let b:current_syntax = 'graphql'
2017-05-17 05:17:16 -04:00
endif