Skip to content

Commit

Permalink
Added OS X and Google Chrome auto refresh with applescripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JamshedVesuna committed Mar 5, 2016
1 parent 68cacb1 commit c56e919
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Binary file added plugin/applescript/activate-vmp.scpt
Binary file not shown.
Binary file added plugin/applescript/search-for-vmp.scpt
Binary file not shown.
20 changes: 18 additions & 2 deletions plugin/vim-markdown-preview.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
" git@github.com:JamshedVesuna/vim-markdown-preview.git
"============================================================

let b:vmp_script_path = resolve(expand('<sfile>:p:h'))

if !exists("g:vim_markdown_preview_browser")
let g:vim_markdown_preview_browser = 'Google Chrome'
endif
Expand Down Expand Up @@ -40,6 +42,8 @@ function! Vim_Markdown_Preview()
endif
if has('mac')
let OSNAME = 'mac'
let b:search_script = b:vmp_script_path . '/applescript/search-for-vmp.scpt'
let b:activate_script = b:vmp_script_path . '/applescript/activate-vmp.scpt'
endif

let curr_file = expand('%:p')
Expand Down Expand Up @@ -68,7 +72,12 @@ function! Vim_Markdown_Preview()
endif

if OSNAME == 'mac'
call system('open -g /tmp/vim-markdown-preview.html')
let b:vmp_preview_in_browser = system('osascript ' . b:search_script)
if b:vmp_preview_in_browser == 1
call system('open -g /tmp/vim-markdown-preview.html')
else
call system('osascript ' . b:activate_script)
endif
endif

if g:vim_markdown_preview_temp_file == 1
Expand All @@ -92,6 +101,8 @@ function! Vim_Markdown_Preview_Local()
endif
if has('mac')
let OSNAME = 'mac'
let b:search_script = b:vmp_script_path . '/applescript/search-for-vmp.scpt'
let b:activate_script = b:vmp_script_path . '/applescript/activate-vmp.scpt'
endif

let curr_file = expand('%:p')
Expand Down Expand Up @@ -120,7 +131,12 @@ function! Vim_Markdown_Preview_Local()
endif

if OSNAME == 'mac'
call system('open -g vim-markdown-preview.html')
let b:vmp_preview_in_browser = system('osascript ' . b:search_script)
if b:vmp_preview_in_browser == 1
call system('open -g /tmp/vim-markdown-preview.html')
else
call system('osascript ' . b:activate_script)
endif
endif

if g:vim_markdown_preview_temp_file == 1
Expand Down

0 comments on commit c56e919

Please sign in to comment.