Skip to content

Instantly share code, notes, and snippets.

@eagletmt
Created September 19, 2013 16:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eagletmt/6625643 to your computer and use it in GitHub Desktop.
Save eagletmt/6625643 to your computer and use it in GitHub Desktop.
let s:hook = {
\ 'kind': 'hook',
\ 'name': 'bundler',
\ }
function! s:hook.on_module_loaded(session, context)
if a:session.config.type !=# 'ruby'
return
endif
if !executable('bundle')
return
endif
let l:lines = split(system(printf('cd %s; ruby -rbundler/shared_helpers -e "puts Bundler::SharedHelpers.in_bundle?"', expand('%:h'))), '\n')
if v:shell_error == 0 && !empty(l:lines) && filereadable(l:lines[0])
let a:session.config.exec = 'env BUNDLE_GEMFILE=' . shellescape(l:lines[0]) . ' bundle exec %C %s'
endif
endfunction
call quickrun#module#register(s:hook)
unlet s:hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment