11bit / zed-extension-graphql

GraphQL support for Zed editor
15 stars 4 forks source link

How to use comments for syntax highlighting? #9

Open Torsten85 opened 1 month ago

Torsten85 commented 1 month ago

Hello, in your features list, you mention that syntax highlighting can be activated using comments (if I understand that correctly).

How does it work?

In vscode im used to writing my typeDefs like:

const typeDefs = /* GraphQL */`
  type MyType {
    id: ID!
  }
`

but that has no effect. Am I missing something?

Thanks in advance

11bit commented 1 month ago

@affanshahid. if I am not mistaken, you've implemented nested graphql language support in zed, right? Maybe you know an answer?

affanshahid commented 1 month ago

Auto-completion should work with GraphQL comments. Syntax highlighting support within other languages is something that depends on Zed directly and currently only supports tags and functions. https://github.com/zed-industries/zed/pull/16368

A workaround would be to define an identity function like const gql = (s) => s; and use that to define queries instead of comments. Like so:

const gql = (s) => s;

const typeDefs = gql(`
  type MyType {
    id: ID!
  }
`)

This should give you syntax highlighting. For specifically using comments I recommend opening an issue on the Zed repo instead.