Skip to content

Instantly share code, notes, and snippets.

@chantastic
Last active February 13, 2024 19:42
Show Gist options
  • Save chantastic/9947601 to your computer and use it in GitHub Desktop.
Save chantastic/9947601 to your computer and use it in GitHub Desktop.
ember-cli VIM projections
{
"app/adapters/*.js": {
"command": "adapter",
"template": [
"// export default DS.{capitalize}Adapter.extend();",
]
},
"app/components/*.js": {
"command": "component",
"template": [
"export default Ember.Component.extend({",
"",
"});",
]
},
"app/controllers/*.js": {
"command": "controller",
"template": [
"export default Ember.Controller.extend({",
"",
"});",
]
},
"app/helpers/*.js": {
"command": "helper",
"template": [
"// Please note that Handlebars helpers will only be found automatically by the",
"// resolver if their name contains a dash (reverse-word, translate-text, etc.)",
"// For more details: http://stefanpenner.github.io/ember-app-kit/guides/using-modules.html",
"",
"export default Ember.Handlebars.makeBoundHelper(function() {",
"",
"});",
]
},
"app/models/*.js": {
"command": "model",
"template": [
"export default DS.Model.extend({",
"",
"});",
]
},
"app/router.js": {
"command": "router"
},
"app/routes/*.js": {
"command": "route",
"template": [
"export default Ember.Route.extend({",
"",
"});",
]
},
"app/styles/*.css": {
"command": "style",
"template": [
"/* {}.css */",
"",
]
},
"app/templates/*.hbs": {
"command": "template"
},
"app/utils/*.js": {
"command": "util"
},
"app/views/*.js": {
"command": "view",
"template": [
"export default Ember.View.extend({",
"",
"});",
]
},
}

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.

TODO

  • Add 'alternate' definitions
@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