GithubHelp home page GithubHelp logo

mklabs / vim-backbone Goto Github PK

View Code? Open in Web Editor NEW
53.0 4.0 5.0 414 KB

Lightweight bag of Vim utilities for Backbone - snipmate snippets, templates and omnicompletion

Vim Script 40.96% JavaScript 59.04%

vim-backbone's Introduction

vim backbone

Collection of Backbone VIM snippets and templates.

Installation

Install for pathogen

cd ~/.vim/bundle
git clone git://github.com/mklabs/vim-backbone.git

Documentation

work in progess

What it does


vim helpfile generated from backbonejs.org (:h backbone)

Backbone helptags


Snipmates snippets. When filetype is set to javascript, type view<tab>, model<tab> or router<tab>

In insert mode, in a file where filetype=javascript, typing view followed by <tab> will expand to the following snippet:

var MyView = Backbone.View.extend({
  el: '',
  tagName: '',

  events: {

  },

  initialize: function () {

  },

  render: function () {

  }
});

Hitting tab again will iterate through snippets placeholders. See :h snipMate and :h snipMate-placeholders for more infos.


Backbone specific omnicompleter.

:h new-omni-completion.

This could also be called "intellisense", but that is a trademark.

Should auto-complete whenever the text in front of the cursor includes a model (this.model triggers the match). Same for collection, router and view.

It works by inspecting the Backbone.Model.prototype object when completing against a match that triggers model completion. It's not as accurate as it would be in your devtool but should be pretty close.

Use CTRL-X CTRL-U in Insert mode to start the completion, when the cursor in in front of the following:

model.
router.
controller.
view.

The plugin also map the <C-Space> (Ctrl+space) to trigger the same omnicompletion.

In insert mode, in a file where filetype=javascript, typing modelor model. followed by either Ctrl+X Ctrl+U or Ctrl+Space will pop the following menu:

Backbone model omnicompleter


What it should do

  • vim templates on BufNewFile. Should this be node-based with mustache like templates, and intelligently parse current filepath / app structure to know which template it should use (eg. opening a new file with something like */models/* or a filename with model in it should trigger the model template.

  • Ease navigation of the Backbone directory structure. eg. easy jumping between files, like model to test, view to template, template to helper, etc.

  • Enhanced syntax highlighting, should this be useful

  • Scripts wrapper around the scripts in the script directory of the Backbone app. A limited amount of completion should be supported

  • Possibly integration and wrappers to build tool

  • should have special logic / behaviour if a spec/ or test/ directory is detected.

  • Commands to generate things. a :Bgenerate model Foo should create a foo controller and edits app/model/foo.js, optionally would be nice to have the matching test generated app/test/foo.js with basic assertions.

vim-backbone's People

Contributors

filirom1 avatar mklabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vim-backbone's Issues

Ease navigation

Ease navigation of the Backbone directory structure. eg. easy jumping between files, like model to test, view to template, template to helper, etc.

Look at https://github.com/tpope/vim-rails for implementation details (and figuring out how to do this :/)

Generate commands

Commands to generate things.

  • a :Bgenerate model Foo should create a foo model and edits app/model/foo.js, optionally would be nice to have the matching test generated app/test/foo.js automatically generated with basic assertions.
:Bgenerate router Foo
>> create app/router/foo.js

:Bgenerate model bar
>> create app/model/bar.js

:Bgenerate view baz
>> create app/views/baz.js

# maybe a second argument to override default path
:Bgenerate view blah blah/blah/blah/view.js
>> create blah/blah/blah/view.js

# maybe convenience scaffolding for template, should be template-engine aware if so
# should be configurable via a plugin option
:Bgenerate template bim
>> create app/templates/bim.hbs

# stylesheets, why not (usually matching / styling a given view)
:Bgenerate style bim
>> create css/ui/bim.hbs

application directory (like model, views directory, etc) should be configurable in some way (views may go in app/views or app/ui, or ./ui, or...)

Option 'completefunc' is not set

In insert mode, editing some .js file, after typing model.<ctrl+x><ctrl+u> I get the errormsg

Option 'completefunc' is not set

I set the completefunc manually to backbone#compl, and got an error from vim-backbone/bin/complete about not knowing backbone.

After I went to the vim-backbone directory, and done npm link backbone, the error vanished, but still I have to manually set the completefunc option to make it work

templates on BufNewFile

Should this be node-based with mustache like templates (eg. use spawned node process and hogan to do the heavy crafting)

  • two args, full filepath and filetype
  • parse current filepath / app structure to know which template it should use (eg. opening a new file with something like /models/ or a filename with model in it should trigger the model template)

Note: Might need to have node_modules committed, or make it clear in install instruction to run npm install.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.