angular.vim : Some niceties for the AngularJS framework
script karma |
Rating 25/11,
Downloaded by 1574 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Kevin Burnett |
|
script type |
ftplugin |
|
description |
Features
Switch to test file and vice versa
:A
A, the "alternate" file, has been mapped to take you from your code to the corresponding test file, or from your test file to the corresponding implementation file. For example, if you're in app/js/rock-socks.js, and you hammer :A, you will be taken to test/spec/rock-socks.js, if such a file exists. Some other common directory structure conventions in the angular community, such as app/src and test/unit, are also supported. Feel free to file a pull request if your reasonable convention doesn't work.
Jump to definition of service/directive/controller/etc
gf
"Go to file" has been slightly overriden to take you to the definition of the file under your cursor. If you're reading some code like this...
if (true) {
AwesomeService.changeStateBecauseMutationIsAwesome();
}
...and your cursor is on AwesomeService, and you hammer gf, if there is a file called awesome-service.js somewhere in a subdirectory of your path, you will be taken there. The default behavior of gf can also be quite useful in the context of an angular app, since html fragments are specified as file paths in views (with ng-include src="full/path.html), directives (with templateUrl: 'src/myapp/modules/main/views//prompt-list.html', so an attempt has been made to allow this to work as well. If all that is missing from a template path is the "app" directory (which is a common value for "cwd" in Gruntfile.js, the plugin will add this for you as well. If either of these two things don't work for your use case, file a ticket, figure out why and file a pull request, or use ctags.
Run the current spec
If you're writing jasmine unit tests for your angular app, they look like this:
it('should work', function() {
var actualThing = 'cow';
expect(actualThing).toEqual('cow');
});
Now, if you take that "it" prefix, and replace it with "iit", instead of running your entire suite, it will run JUST THAT ONE SPEC. There are probably bad reasons to want to do this, like if your build is broken and you only want to fix your code, but it can be pretty handy to focus in on just one spec at a time (and one spec generally runs way fast).
So, if you're anywhere inside a spec:
:AngularRunSpec
or the "run spec" mapping:
<leader>rs
will toggle the spec between "it" and "iit." This works especially well if you have a karma watch going. See the screencast at http://notkeepingitreal.com (soon come). |
|
install details |
Extract in ~/.vim or ~\vimfiles.
Grab the very latest from http://github.com/burnettk/vim-angular |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 18.97.14.85
|