aboutsummaryrefslogtreecommitdiff
path: root/runtime/syntax/graphql.vim
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /runtime/syntax/graphql.vim
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-rahm.tar.gz
rneovim-rahm.tar.bz2
rneovim-rahm.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'runtime/syntax/graphql.vim')
-rw-r--r--runtime/syntax/graphql.vim90
1 files changed, 90 insertions, 0 deletions
diff --git a/runtime/syntax/graphql.vim b/runtime/syntax/graphql.vim
new file mode 100644
index 0000000000..01d5ca25ff
--- /dev/null
+++ b/runtime/syntax/graphql.vim
@@ -0,0 +1,90 @@
+" Vim syntax file
+" Language: graphql
+" Maintainer: Jon Parise <jon@indelible.org>
+" Filenames: *.graphql *.graphqls *.gql
+" URL: https://github.com/jparise/vim-graphql
+" License: MIT <https://opensource.org/license/mit>
+" Last Change: 2024 Dec 21
+
+if !exists('main_syntax')
+ if exists('b:current_syntax')
+ finish
+ endif
+ let main_syntax = 'graphql'
+endif
+
+syn case match
+
+syn match graphqlComment "#.*$" contains=@Spell
+
+syn match graphqlOperator "=" display
+syn match graphqlOperator "!" display
+syn match graphqlOperator "|" display
+syn match graphqlOperator "&" display
+syn match graphqlOperator "\M..." display
+
+syn keyword graphqlBoolean true false
+syn keyword graphqlNull null
+syn match graphqlNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>" display
+syn region graphqlString start=+"+ skip=+\\\\\|\\"+ end=+"\|$+
+syn region graphqlString start=+"""+ skip=+\\"""+ end=+"""+
+
+syn keyword graphqlKeyword repeatable nextgroup=graphqlKeyword skipwhite
+syn keyword graphqlKeyword on nextgroup=graphqlType,graphqlDirectiveLocation 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=graphqlName skipwhite
+syn keyword graphqlStructure directive nextgroup=graphqlDirective skipwhite
+syn keyword graphqlStructure extend nextgroup=graphqlStructure skipwhite
+syn keyword graphqlStructure schema nextgroup=graphqlFold skipwhite
+
+syn match graphqlDirective "\<@\h\w*\>" display
+syn match graphqlVariable "\<\$\h\w*\>" display
+syn match graphqlName "\<\h\w*\>" display
+syn match graphqlType "\<_*\u\w*\>" display
+
+" https://spec.graphql.org/October2021/#ExecutableDirectiveLocation
+syn keyword graphqlDirectiveLocation QUERY MUTATION SUBSCRIPTION FIELD
+syn keyword graphqlDirectiveLocation FRAGMENT_DEFINITION FRAGMENT_SPREAD
+syn keyword graphqlDirectiveLocation INLINE_FRAGMENT VARIABLE_DEFINITION
+" https://spec.graphql.org/October2021/#TypeSystemDirectiveLocation
+syn keyword graphqlDirectiveLocation SCHEMA SCALAR OBJECT FIELD_DEFINITION
+syn keyword graphqlDirectiveLocation ARGUMENT_DEFINITION INTERFACE UNION
+syn keyword graphqlDirectiveLocation ENUM ENUM_VALUE INPUT_OBJECT
+syn keyword graphqlDirectiveLocation INPUT_FIELD_DEFINITION
+
+syn keyword graphqlMetaFields __schema __type __typename
+
+syn region graphqlFold matchgroup=graphqlBraces start="{" end="}" transparent fold contains=ALLBUT,graphqlStructure
+syn region graphqlList matchgroup=graphqlBraces start="\[" end="]" transparent contains=ALLBUT,graphqlDirective,graphqlStructure
+
+if main_syntax ==# 'graphql'
+ syn sync minlines=500
+endif
+
+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 graphqlDirective PreProc
+hi def link graphqlDirectiveLocation Special
+hi def link graphqlName 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
+
+let b:current_syntax = 'graphql'
+
+if main_syntax ==# 'graphql'
+ unlet main_syntax
+endif