Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Forked from chantastic/.projections.json
Last active August 20, 2017 19:10
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeremywrowe/ee508f16b56c8c1a7223 to your computer and use it in GitHub Desktop.
Save jeremywrowe/ee508f16b56c8c1a7223 to your computer and use it in GitHub Desktop.
ember-cli VIM projections
{
"app/adapters/*.js": {
"command": "adapter",
"template": [
"import ApplicationAdapter from './application';",
"",
"export default ApplicationAdapter.extend({",
"",
"});"
],
"alternate": "tests/unit/adapters/{}-test.js"
},
"tests/unit/adapters/*-test.js": {
"command": "adapterTest",
"template": [
"import {open} moduleFor, test {close} from 'ember-qunit';",
"",
"moduleFor('adapter:{}');",
"",
"test('it adapts', function(assert) {",
" var adapter = this.subject();",
" assert.ok(adapter);",
"});"
],
"alternate": "app/adapters/{}.js"
},
"app/components/*.js": {
"command": "component",
"template": [
"import Ember from 'ember';",
"",
"export default Ember.Component.extend({",
"",
"});"
],
"alternate": "tests/integration/components/{}-test.js"
},
"tests/integration/components/*-test.js": {
"command": "componentTest",
"template": [
"import {open} moduleForComponent, test {close} from 'ember-qunit';",
"import t from 'htmlbars-inline-precompile';",
"",
"moduleForComponent('{}', 'component:{}', {",
" integration: true",
"});",
"",
"test('it is a dom building block', function(assert) {",
" this.render(t`{open}{open}{}{close}{close}`);",
" assert.equal(this.$().text().trim(), 'bob the builder');",
"});"
],
"alternate": "app/components/{}.js"
},
"app/controllers/*.js": {
"command": "controller",
"template": [
"import Ember from 'ember';",
"",
"export default Ember.Controller.extend({",
"",
"});"
],
"alternate": "tests/unit/controllers/{}-test.js"
},
"tests/unit/controllers/*-test.js": {
"command": "controllerTest",
"template": [
"import {open} moduleFor, test {close} from 'ember-qunit';",
"",
"moduleFor('controller:{}', {open} {close});",
"",
"test('it remote controls', function(assert) {",
" var controller = this.subject();",
" assert.ok(controller);",
"});"
],
"alternate": "app/controllers/{}.js"
},
"app/helpers/*.js": {
"command": "helper",
"template": [
"import Ember from 'ember';",
"",
"export function {camelcase}(params/*, hash*/) {",
" return params;",
"}",
"",
"export default Ember.Helper.helper({camelcase});"
],
"alternate": "tests/unit/helpers/{}-test.js"
},
"tests/unit/helpers/*-test.js": {
"command": "helperTest",
"template": [
"import {open} {camelcase} {close} from '../../../helpers/{}';",
"import {open} module, test {close} from 'qunit';",
"",
"module('helper:{}');",
"",
"test('aide', function(assert) {",
" let result = {camelcase}();",
" assert.equal(result, 'a winner is you');",
"});"
],
"alternate": "app/helpers/{}.js"
},
"app/models/*.js": {
"command": "model",
"template": [
"import DS from 'ember-data';",
"export default DS.Model.extend({",
"",
"});"
],
"alternate": "tests/unit/models/{}-test.js"
},
"tests/unit/models/*-test.js": {
"command": "modelTest",
"template": [
"import {open} moduleForModel, test {close} from 'ember-qunit';",
"",
"moduleForModel('{}', 'model:{}');",
"",
"test('fashion show', function(assert) {",
" let model = this.subject();",
" // let store = this.store();",
" assert.equal(model.get('appleBottomJeans'), 'Boots with the fur');",
"});"
],
"alternate": "app/models/{}.js"
},
"app/router.js": {
"command": "router"
},
"app/routes/*.js": {
"command": "route",
"template": [
"import Ember from 'ember';",
"",
"export default Ember.Route.extend({",
"",
"});"
],
"alternate": "tests/unit/routes/{}-test.js"
},
"tests/unit/routes/*-test.js": {
"command": "routeTest",
"template": [
"import {open} moduleFor, test {close} from 'ember-qunit';",
"",
"moduleFor('route:{}');",
"",
"test('path to success', function(assert) {",
" let route = this.subject();",
" route.send('action', 1);",
" assert.equal(route.get('actionResult'), 1);",
"});"
],
"alternate": "app/routes/{}.js"
},
"app/templates/*.hbs": {
"command": "template",
"alternate": "app/components/{}.js"
},
"app/utils/*.js": {
"command": "util"
}
}

ember-cli VIM projections

This is a small projections.vim file for for ember-cli.

It's designed for use with Tim Popes projectile.vim—a general purpose plugin, based on the beloved rails.vim. If you use rails.vim, this will make you feel right at home with ember-cli.

You'll need to it Install projectile.vim to start using these projectins in your ember project.

Once projectile is installed, simply add this .projections.json file to the root of your ember application. You can also add it to your your .vimrc file—with a little tinkering.

Now you have access to commands like Erouter, to edit app/router.js, or Ehelper reverse-word to edit app/helpers/reverse-word.js.

In addition to E (edit), you can use the S (split), T (tabedit) and V (vsplit) prefixes when editing a file.

Creating a File

You can create a file with any command by passing in a file path that does not exist and pressing return. You will get a new buffer with ES6 Module boilerplate for the specified type. For example: if app/components/my-calendar does not exist, executing Ecomponent my-calander will give you a new component with ember-component with in ES6 Module-style syntax.

@seanpdoyle
Copy link

FYI, with Ember versions > 1.13.x, you can have single-word helpers:

  "app/helpers/*.js": {
    "command": "helper",
    "template": [
      "export default Ember.Helper.helper(function() {",
      "",
      "});",
    ]
  },

@jeremywrowe
Copy link
Author

thanks @seandoyle I updated the gist

@jrock2004
Copy link

So if we were to add this to our vimrc, what would we name it? let g:ember_projections? Also could this file go into ftplugin or ftdetect folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment