Skip to content

Commit 1d22524

Browse files
committed
Use dispatch.vim's new -dir= and =expr
This enables using :0FocusCommand and :.FocusCommand to see the exact rake task that will run.
1 parent e537c71 commit 1d22524

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

autoload/rails.vim

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4859,15 +4859,28 @@ function! rails#buffer_setup() abort
48594859
let &l:makeprg = self.app().rake_command('static')
48604860
let &l:errorformat .= ',chdir '.escape(self.app().path(), ',')
48614861

4862-
if self.type_name('test', 'spec', 'cucumber')
4863-
call self.setvar('dispatch', ':Runner')
4864-
elseif self.name() ==# 'Rakefile'
4865-
call self.setvar('dispatch', ':Rake --tasks')
4866-
elseif self.name() =~# '^\%(app\|config\|db\|lib\|log\|README\)'
4867-
call self.setvar('dispatch', ':Rake')
4868-
elseif self.name() =~# '^public'
4862+
if exists(':Dispatch') == 2 && !exists('g:autoloaded_dispatch')
4863+
runtime! autoload/dispatch.vim
4864+
endif
4865+
if exists('*dispatch#dir_opt')
4866+
let dir = dispatch#dir_opt(self.app().path())
4867+
endif
4868+
4869+
if self.name() =~# '^public'
48694870
call self.setvar('dispatch', ':Preview')
4871+
elseif self.type_name('test', 'spec', 'cucumber')
4872+
call self.setvar('dispatch', ':Runner')
4873+
elseif self.name() =~# '^\%(app\|config\|db\|lib\|log\|README\|Rakefile\)'
4874+
if exists('dir')
4875+
call self.setvar('dispatch',
4876+
\ dir . '-compiler=rails ' .
4877+
\ self.app().rake_command('static') .
4878+
\ ' `=rails#buffer(' . self['#'] . ').default_rake_task(v:lnum)`')
4879+
else
4880+
call self.setvar('dispatch', ':Rake')
4881+
endif
48704882
endif
4883+
48714884
if empty(self.getvar('start'))
48724885
call self.setvar('start', ':Server')
48734886
endif

0 commit comments

Comments
 (0)