Skip to content

Commit 22e136e

Browse files
committed
fix burnettk#17: allow users to turn off alternate functionality
1 parent 72999fa commit 22e136e

4 files changed

Lines changed: 31 additions & 8 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ If there is a common convention that you feel should really work out of
5252
the box, feel free to file a pull request to make it work (please
5353
include a test to prove that it works).
5454

55+
If you don't want to use the alternate functionality, set this before the
56+
plugin loads:
57+
58+
```
59+
let g:angular_skip_alternate_mappings = 1
60+
```
61+
5562
### Jump to definition of service/directive/controller/etc
5663

5764
gf

doc/angular.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ gf Bolsters the original gf by also sending you to the
3737
That's ok; you can tell angular.vim where your source
3838
and test directories are located with
3939
g:angular_source_directory and
40-
g:angular_test_directory.
40+
g:angular_test_directory. You can disable this
41+
functionality by doing this before the plugin loads:
42+
let g:angular_skip_alternate_mappings = 1
4143

4244
*angular-:AS*
4345
:AS Like :A, but in a split.

plugin/angular.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,15 @@ augroup angular_gf
296296
autocmd FileType javascript,html nmap <buffer> <C-W>gf <Plug>AngularGfTabjump
297297
augroup END
298298

299-
augroup angular_alternate
300-
autocmd!
301-
autocmd FileType javascript command! -buffer -bar -bang A :exe s:Alternate('edit<bang>')
302-
autocmd FileType javascript command! -buffer -bar AS :exe s:Alternate('split')
303-
autocmd FileType javascript command! -buffer -bar AV :exe s:Alternate('vsplit')
304-
autocmd FileType javascript command! -buffer -bar AT :exe s:Alternate('tabedit')
305-
augroup END
299+
if !exists('g:angular_skip_alternate_mappings')
300+
augroup angular_alternate
301+
autocmd!
302+
autocmd FileType javascript command! -buffer -bar -bang A :exe s:Alternate('edit<bang>')
303+
autocmd FileType javascript command! -buffer -bar AS :exe s:Alternate('split')
304+
autocmd FileType javascript command! -buffer -bar AV :exe s:Alternate('vsplit')
305+
autocmd FileType javascript command! -buffer -bar AT :exe s:Alternate('tabedit')
306+
augroup END
307+
endif
306308

307309
augroup angular_run_spec
308310
autocmd!

spec/alternate_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
assume_blank_vimrc_by_unsetting_any_global_variables
77
end
88

9+
# g:angular_skip_alternate_mappings is used at angular.vim load
10+
# time, so it's not as simple as this to test it.
11+
# specify "should allow user to disable alternates" do
12+
# assume_vimrc('let g:angular_skip_alternate_mappings = "true"')
13+
# file_a = 'app/src/poo.js'
14+
# file_b = 'test/unit/poo.js'
15+
# setup_filesystem(file_a, file_b)
16+
# vim.edit file_a
17+
# vim.command 'A'
18+
# current_file_name.should eq file_a
19+
# end
20+
921
specify "pairs that should work" do
1022
should_alternate_between('app/src/poo.js', 'test/unit/poo.js')
1123
should_alternate_between('app/src/poo.js', 'test/unit/poo.spec.js')

0 commit comments

Comments
 (0)