Ⅰ. 插件描述
A Vim plugin that provides GraphQL file detection, syntax highlighting, and indentation.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'jparise/vim-graphql'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'jparise/vim-graphql'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'jparise/vim-graphql'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/jparise/vim-graphql
Ⅳ. 文档说明
# GraphQL for Vim
This Vim plugin provides GraphQL file detection,
syntax highlighting, and indentation. It currently targets the [June 2018
edition](https://graphql.github.io/graphql-spec/June2018/) of the GraphQL
specification.
Installation
Using vim-plug
- Add
Plug 'jparise/vim-graphql'to~/.vimrc 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 qSyntax 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 graphqlJavaScript and TypeScript Support
GraphQL syntax support inside of ES2015 template literals is
- It works "out of the box" with Vim 8.2+'s JavaScript and TypeScript
- 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"].
Syntax highlighting within .jsx / .tsx files is also supported. These
filetypes can be "compound" (javascript.jsx) or use the "react" variant
(javascriptreact).
Syntax highlighting is also available within Vue
templates.
Testing
The test suite uses Vader.vim. To run
all of the tests from the command line:
make testLicense
This code is released under the terms of the MIT license. See LICENSE for
details.