A Vim plugin that provides GraphQL file detection, syntax highlighting, and indentation.
Switch branches/tags
Nothing to show
Clone or download

README.md

GraphQL for Vim

This is a Vim plugin that provides GraphQL file detection, syntax highlighting, and indentation. It currently targets the October 2016 draft specification.

Installation

Using Plug

  1. Add Plug 'jparise/vim-graphql' to ~/.vimrc
  2. vim +PluginInstall +qall

Using Vundle

  1. Add Plugin 'jparise/vim-graphql' to ~/.vimrc
  2. vim +PluginInstall +qall

Using Pathogen

  1. cd ~/.vim/bundle
  2. git clone https://github.com/jparise/vim-graphql.git

Syntax Highlighting

Complete syntax highlighting is enable for the graphql filetype. This filetype is automatically selected for file names ending in .graphql, .graphqls, and .gql.

JavaScript / TypeScript Support

When the vim-javascript or yats plugins are installed, GraphQL syntax support in ES2015 template literals is enabled.

const query = gql`
  {
    user(id: ${uid}) {
      firstName
      lastName
    }
  }
`;

The list of recognized tag names is defined by the g:graphql_javascript_tags variable, which defaults to ["gql", "graphql", "Relay.QL"].

Testing

The test suite uses Vader.vim. To run all of the tests from the command line:

$ make test