brunch (with Backbone)A vim plugin for
Inspired by vim-rails this plugin makes navigating through your brunch projects a lot more comfortable. Besides an interface to the brunch command line it offers Ex commands to quickly move from one brunch file to one of its related files.
Want to open your user model? Type
:Bmodel user. Need the corresponding unit test in a vertical split? Just go
Preferred method: Vundle
- Install with vundle
Bundle 'drichard/vim-brunch'to your vimrc
- Save and call
Download zip/tarball and extract contents into your .vim directory
git clone git://github.com/drichard/vim-brunch.git cd vim-brunch cp -R * ~/.vim
Vim-brunch expects that you start Vim inside the root folder of your brunch project. When a brunch project has been detected the following commands are available:
Opens the model for the current module or opens the model with the optionally given name.
Opens the view for the current module.
Opens the controller for the current module.
Opens the template for the current module.
Opens the stylesheet for the current module.
Opens the test for the current file. Inside a model this will open the unit test for a model, inside a view it opens the view_test etc. Inside a template, for example, this command doesn't make much sense.
To open a specific test file name should be the filename of the module. The script will then try to figure out which test you want to open. For example, for
:Btest user it would assume that you would like to open the test for the user model, whereas
:Btest user_view will open the test for the user view.
In combination with the bang modifier this commands makes a handy shortcut for creating test files.
:Btest! todo_view will create an empty test file in
Opens the config file for the project.
Opens index.html in app/assets/index.html.
Builds the project. Same as
:Bgenerate <type> <name> [options]
Generate files from template. Same as
:Bdestroy <type> <name> [options]
Destroys changes made by
:Bgenerate. Same as
Runs all tests for the current project. Same as
brunch test. Requires brunch 1.3+.
Features and Hints
Bang modifier: The commands [model, view, controller, template, style, test] accept a bang modifier which creates a new file if it does not exist yet.
:Bcontroller! home -> Would create app/controllers/home_controller.coffee if it isn't there yet. :Btest! -> Create the corresponding test file
When called without an argument the commands with an optional [name] argument will open the appropriate file based on the file in the current buffer. However, you can specify a module name if you like to open an unrelated module.
:Bview -> Opens app/views/todo_view.coffee
:Bview todolist -> Opens app/views/todolist_view.coffee
Auto completion: All commands that accept an optional [name] argument offer context based auto completion. For example,
:Bmodel t<TAB>would auto complete all models starting with 't'.
Split windows: The navigation commands can also be called as
:BSviewwhich will then open the file in a vertical or horizontal split window.
:BStemplate user -> Opens app/views/templates/user.styl in horizontal split window.
The plugin makes a lot of assumptions about how you name your files and where you put them. If you don't follow the brunch conventions all hell will break lose, the undead will rise again and not much will work really.
For now the plugin does not detect which brunch skeleton you are using, so by default it expects the standard directory structure with Backbone.js, CoffeeScript, Handlebars and Stylus. If you want to change those settings, the following global variables are defined:
The directory of the app folder.
The directory of the test folder.
The extension for script files.
The extension for stylesheets.
The extension for templates.
The delimiter in file names, _ or -.
Inside your .vimrc:
- Add support for
- Detect brunch settings based config.coffee