diff --git a/README.md b/README.md index 6121cc8..395cd4c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ If the test file is missing you can create it on the fly. - In PHP if you open `src/Name/App.php` and issue `tt` the plugin tries to open `tests/Name/AppTest.php` - In Golang if you open `boat.go` and issue `tt` the plugin tries to open `boat_test.go` +- In Java if you open the class AppController.java under the package com.mycompany.App and issue ``tt`` the plugin tries to open the class `AppControllerTest.java` under the same package ... And viceversa! ;-) diff --git a/plugin/relatedtest.vim b/plugin/relatedtest.vim index 49f5a5e..f096f74 100644 --- a/plugin/relatedtest.vim +++ b/plugin/relatedtest.vim @@ -16,6 +16,23 @@ if !exists('g:relatedtest_open_command') let g:relatedtest_open_command = 'tt' endif +let available_extensions = [ + \ '\.php$', + \ '\.go$', + \ '\.java$' + \ ] + +let is_available = 0 +for pattern in available_extensions + if bufname('%') =~ pattern + let is_available = 1 + endif +endfor + +if is_available == 0 + finish +endif + function! g:relatedTestHandleTT() let a:bufname = bufname('%') if b:relatedTestIsTest(a:bufname) > 0