ember.vim


Ⅰ. 插件描述

Vim plugin for the Emberjs frontend framework

Ⅱ. 基本信息

创建日期:  2013-10-10
使用用户:  97
Github星:  114
插件作者:  Darshan Sawardekar

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'dsawardekar/ember-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'dsawardekar/ember-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'dsawardekar/ember-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/dsawardekar/ember.vim

Ⅳ. 文档说明

# Ember.vim Build Status Dependency Status

Ember.vim is a Vim plugin for the Emberjs frontend framework inspired by vim-rails.

The core feature set is derived from Portkey. Briefly, Portkey provides the foundation needed to
do vim-rails style :Alternate, :Related navigation within an Emberjs project.
This plugin provides default projections for a typical ember project.

Features

  • Alternate and Related navigation with :A and :R
  • Resource navigation with :(E|S|T|V|D)resource
  • CtrlP based fuzzy searching for resources
  • New file creation with :Emodel post!
  • Simple refactoring with :<range>Esource destination
  • Ember Appkit based project layout
  • Boilerplate for Javascript and Coffeescript files
  • Improved syntax highlighting for Javascript, Coffeescript and Handlebars files

Usage

After installing the Portkey and Ember.vim plugins, Create a portkey.json in your project root with
contents like below,

{
  "portkeys": ["ember"]
}

Then reload the file with,

:e!

That' it. This will load the ember extension with the Ember Appkit file layout and Javascript
boilerplate.

Supported Layouts

The default extension follows the Ember Appkit layout. The expected
layout of files in your ember project is,

app/
├── models
├── routes
├── controllers
├── views
├── templates
├── components
├── helpers
├── styles
│
├── app.js
├── store.js
└── router.js

You can add additional patterns to the portkey.json to match additions to your project.

{
  "app/adapters/*.js": {
    "type": "adapter",
    "test": "tests/adapters/%s_test.js"
  }
}

Here a custom projection for adapters is added to match files in the app/adapters folder.

Supported Variations

By default the extension will use Javascript file patterns and Appkit based boilerplate templates. You can
choose a different portkey.json variant using the syntax, ember:variant-lang.

{
  "portkeys": ["ember:classic-coffee"]
}

Here ember with classic boilerplate with coffeescript file patterns will be used.

The following variations are supported.

  1. appkit or appkit-js
    This is the default layout when a variant is not specified. It contains boilerplate templates

for the es6 module transpiler.

  1. appkit-coffee:
    Ember Appkit with Coffee script boilerplate and patterns.
  2. classic or classic-js:
    Classic Emberjs boilerplate in Javascript.
  3. classic-coffee
    Classic with Coffeescript boilerplate and patterns.
  4. custom ie: ember:custom
    No default file patterns, patterns from portkey.json are used instead. Allows use of

syntax highlighting and filters from the ember extension.

Navigation with Alternate & Related

Portkeys Ex commands :A and :R navigate to the alternate and related
files relative to the current file.

The default alternate and related varies based on the current file. The
table below lists these relations.

ResourceAlternateRelated
modelroutecontroller
routemodelcontroller or template
controllerroute + modeltemplate + view
templateroute + modelcontroller + view
viewroute + modelcontroller + template
componentnonetemplate

Navigation with Resource Ex commands

The Emberjs resources like models, controllers, routes, etc get their own
Ex command.

:Emodel post opens the Post model in the current buffer.
:Scontroller post opens the PostController in a horizontal split.

In addition the resource command can resolve the target resource from the
current buffer's name.

:Eroute in the post model, will go to the PostRoute.

The resource commands have variants E, S, V, T and D that
can be used to customize the window to open the file in.

See here for details on these variants.

Creating new Files

To create a new file, use the corresponding resource command with bang.

:Emodel comment!

This will create a new comment model, app/models/comment.js.

The :A and :R commands can also be used with bang to
create new files.

The related for models as described in the table above
is a controller. So from the Post model use,

:R!

to create the file, app/controllers/post.js.

Navigation with CtrlP

With CtrlP, Portkey provides the following default mappings. These
mappings open a CtrlP menu with a list of resource of that type.

Hitting enter opens the resource in the current window. Ctrl-v and Ctrl-s open
the file in vertical or horizontal splits respectively.

MappingResource
<LocalLeader>cmcomponent
<LocalLeader>cncontroller
<LocalLeader>apapp
<LocalLeader>rroute
<LocalLeader>sstylesheet
<LocalLeader>tstest
<LocalLeader>tmtemplate
<LocalLeader>vview
<LocalLeader>ggrunt
<LocalLeader>hhelper
<LocalLeader>mmodel

Customization

Any additional projections in your portkey.json take precedence over the
extension's projections. Additional patterns are merged with existing ones.

For Eg:- To change the template for models use,

{
  "app/models/*.js": {
    "type": "model",
    "template": "MyApp.Model = Em.Model.extend({\n\t\n});"
  }
}

System Requirements

Ember.vim is an extension of Portkey. See here
for instructions on how to install Portkey.

In addition the following plugins are recommended.

Installation

1. With Vundle

Plugin 'dsawardekar/ember.vim'

2. With Pathogen

git clone https://github.com/dsawardekar/ember.vim ~/.vim/bundle/ember.vim

TODO

  • Improve Portkey's Extractor.
  • Improve Portkey's GetFile Finder.
  • Vim compiler plugin to run grunt test with :Run

Authors

Thanks

  1. Yehuda Katz and the Emberjs team for Ember.
  2. Tim Pope - For vim-rails.
  3. Stefan Penner - For ember-appkit.

Contributing

See instructions for Portkey.

License

MIT License. Copyright © 2013 Darshan Sawardekar.

添加新评论