mirror of
https://github.com/nvim-treesitter/nvim-treesitter-context
synced 2024-09-16 14:14:03 +02:00
feat(graphql): graphql support
This commit is contained in:
parent
75b3a0422a
commit
3f33c28f3c
3 changed files with 110 additions and 1 deletions
|
@ -40,6 +40,7 @@ use 'nvim-treesitter/nvim-treesitter-context'
|
|||
- [x] `elixir`
|
||||
- [x] `fish`
|
||||
- [x] `go`
|
||||
- [x] `graphql`
|
||||
- [x] `ini`
|
||||
- [x] `java`
|
||||
- [x] `javascript`
|
||||
|
@ -109,7 +110,6 @@ use 'nvim-treesitter/nvim-treesitter-context'
|
|||
- [ ] `gomod`
|
||||
- [ ] `gosum`
|
||||
- [ ] `gowork`
|
||||
- [ ] `graphql`
|
||||
- [ ] `hack`
|
||||
- [ ] `haskell`
|
||||
- [ ] `hcl`
|
||||
|
|
30
queries/graphql/context.scm
Normal file
30
queries/graphql/context.scm
Normal file
|
@ -0,0 +1,30 @@
|
|||
(interface_type_definition
|
||||
(fields_definition (_) @context.end)
|
||||
) @context
|
||||
|
||||
(object_type_definition
|
||||
(fields_definition (_) @context.end)
|
||||
) @context
|
||||
|
||||
(schema_definition
|
||||
(_) @context.end
|
||||
) @context
|
||||
|
||||
(input_object_type_definition
|
||||
(input_fields_definition (_) @context.end)
|
||||
) @context
|
||||
|
||||
(operation_definition
|
||||
(selection_set (_) @context.end)
|
||||
) @context
|
||||
|
||||
(inline_fragment
|
||||
(selection_set (_) @context.end)
|
||||
) @context
|
||||
|
||||
(selection
|
||||
(field
|
||||
(arguments)
|
||||
(selection_set (_) @context.end)
|
||||
)
|
||||
) @context
|
79
test/test.graphql
Normal file
79
test/test.graphql
Normal file
|
@ -0,0 +1,79 @@
|
|||
interface
|
||||
Foo
|
||||
{
|
||||
id: ID!
|
||||
name: String
|
||||
|
||||
|
||||
}
|
||||
|
||||
input
|
||||
Stuff {
|
||||
limit: Int
|
||||
since_id: ID
|
||||
|
||||
}
|
||||
|
||||
type Bar
|
||||
implements Foo {
|
||||
age: Int
|
||||
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
addBar(name: String, age: int): Bar
|
||||
}
|
||||
|
||||
query Stuff {
|
||||
name
|
||||
foo {
|
||||
name
|
||||
}
|
||||
}
|
||||
|
||||
query GetSearchResults {
|
||||
search(contains: "Shakespeare") {
|
||||
__typename
|
||||
# inline fragment
|
||||
... on Book {
|
||||
title
|
||||
}
|
||||
... on Author {
|
||||
name
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mutation
|
||||
CreateBar {
|
||||
addBar(name: "AAAA",
|
||||
age: 42) {
|
||||
name
|
||||
foo {
|
||||
age
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Root {
|
||||
name: String
|
||||
|
||||
|
||||
}
|
||||
|
||||
schema {
|
||||
query: Root
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue