jaxbot / browserlink.vim

Live browser editing for Vim
MIT License
711 stars 38 forks source link

Error when opening html or css when brolink node app not running. #8

Closed TheInsomniac closed 11 years ago

TheInsomniac commented 11 years ago

Suggested fix: Default to g:bl_no_implystart=1 (or place in vimrc) Modify brolink.vim so that one calls Brolink manually in vim for files that they would like live preview enabled on.

function! s:Start()
  if !exists("g:bl_no_autoupdate")
    if has('mac')
      silent !open '%:p'
      redraw!
    endif
  call s:setupHandlers()
  endif
au VimLeave * :BLDisconnect
call s:Connect()
endfunction

if !exists("g:bl_no_implystart")
    call s:Start()
endif

command Brolink call <SID>Start()

My change also auto opens the html in the default browser on OSX and moves the Disconnect to the start function or you end up with errors every time vim exits if Brolink hasn't been called yet.

Then in vim when editing an html that you want live preview enabled (and if brolink node app is running) run :Brolink

TheInsomniac commented 11 years ago

One could also add the following for windows (I believe):

if has('win32')
  silent !cmd 'start %:p'
  redraw!
endif