• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

jparise/vim-graphql: A Vim plugin that provides GraphQL file detection, syntax h ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

jparise/vim-graphql

开源软件地址(OpenSource Url):

https://github.com/jparise/vim-graphql

开源编程语言(OpenSource Language):

Vim Script 97.6%

开源软件介绍(OpenSource Introduction):

GraphQL for Vim

This Vim plugin provides GraphQL file detection, syntax highlighting, and indentation. It currently targets the June 2018 edition of the GraphQL specification.

Installation

This plugin requires Vim version 8 or later. Equivalent Neovim versions are also supported.

Using vim-plug

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

Using Vim Packages

mkdir -p ~/.vim/pack/jparise/start
cd ~/.vim/pack/jparise/start
git clone https://github.com/jparise/vim-graphql.git graphql
vim -u NONE -c "helptags graphql/doc" -c q

Syntax Highlighting

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

If you would like to enable automatic syntax support for more file extensions (e.g., *.prisma), create a file named ~/.vim/after/ftdetect/graphql.vim containing autocommand lines like:

au BufNewFile,BufRead *.prisma setfiletype graphql

JavaScript and TypeScript Support

GraphQL syntax support inside of ES2015 template literals is provided. It works "out of the box" with Vim 8.2+'s JavaScript and TypeScript language support. The extended JavaScript syntax provided by the vim-javascript plugin is also supported.

For older versions of Vim, TypeScript support can be enabled by installing the yats plugin.

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"].

You can also add a # gql or # graphql comment at the start of a template string to indicate that its contents should be considered GraphQL syntax.

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

Syntax highlighting within .jsx / .tsx files is also supported. These filetypes can be "compound" (javascript.jsx and typescript.tsx) or use the "react" variants (javascriptreact and typescriptreact).

Syntax highlighting is also available within Vue templates.

ReasonML Support

GraphQL syntax support inside of ReasonML template strings using graphql-ppx is available.

[%graphql {|
  query UserQuery {
    user {
      id
      name
    }
  }
|}];

The %relay extension point is also supported.

ReScript Support

GraphQL syntax support inside of ReScript strings is available.

%graphql(`
  query UserQuery {
    user {
      id
      name
    }
  }
`)

The %relay extension node is also supported.

PHP Support

GraphQL syntax inside of heredoc and nowdoc strings is supported. The string identifier must be named GQL (case-insensitive).

<?php
$my_query = <<<GQL
{
  user(id: ${uid}) {
    firstName
    lastName
  }
}
GQL;

Language Server Protocol Support

Language Server Protocol (LSP) implementations can enable editor features like schema-aware completion.

Testing

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

make test

License

This code is released under the terms of the MIT license. See LICENSE for details.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap