Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add firefox support. #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions plugin/vim-markdown-preview.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,31 @@ function! Vim_Markdown_Preview()
call system('pandoc --smart --standalone "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
else
call system('markdown "' . b:curr_file . '" > /tmp/vim-markdown-preview.html')
if g:vim_markdown_preview_browser == 'firefox'
" prepend html title, allowing xdotool to find the browser when updating
call system('echo -e "<title>vim-markdown-preview.html</title>\n$(cat /tmp/vim-markdown-preview.html)" > /tmp/vim-markdown-preview.html')
endif
endif
if v:shell_error
echo 'Please install the necessary requirements: https://github.com/JamshedVesuna/vim-markdown-preview#requirements'
endif

if g:vmp_osname == 'unix'
let chrome_wid = system("xdotool search --name 'vim-markdown-preview.html - " . g:vim_markdown_preview_browser . "'")
if !chrome_wid
if g:vim_markdown_preview_browser == 'firefox'
let browser_wid = system("xdotool search --name 'vim-markdown-preview.html'")
else
let browser_wid = system("xdotool search --name 'vim-markdown-preview.html - " . g:vim_markdown_preview_browser . "'")
endif
if !browser_wid
if g:vim_markdown_preview_use_xdg_open == 1
call system('xdg-open /tmp/vim-markdown-preview.html 1>/dev/null 2>/dev/null &')
else
call system('see /tmp/vim-markdown-preview.html 1>/dev/null 2>/dev/null &')
endif
else
let curr_wid = system('xdotool getwindowfocus')
call system('xdotool windowmap ' . chrome_wid)
call system('xdotool windowactivate ' . chrome_wid)
call system('xdotool windowmap ' . browser_wid)
call system('xdotool windowactivate ' . browser_wid)
call system("xdotool key 'ctrl+r'")
call system('xdotool windowactivate ' . curr_wid)
endif
Expand Down