vim-markdown-preview
vim-markdown-preview copied to clipboard
Opens new tab when called on Ubuntu 16 with firefox
I have firefox as the standard browser (it is what came installed in the distro), and whenever I do <C-p> a new tab opens. How can I fix this?
We still need to add Firefox as a supported browser. If you are on linux, xdotool should be refreshing the tab instead of creating a new one. You can try manually creating the html file
then calling xdotool to see if its a system problem.
Calling xdotool by hand using the way you pointed doesn't cause anything to happen (I was inside the folder with the markdown-preview.html.
I have installed chrome and I still get a new tab when using <C-p>. Addionally, both in chrome and firefox my code blocks and bullet points don't render (they appear raw, as typed in the document).
The issue is that xdotool does not find the browser window that already displays the html file because it searches for the wrong title.
I implemented a workaround by setting the html title when creating the html and make xdotool explicitely search for it when updating/displaying the html. Check out the fork here. I can submit a PR if it works for you.
Remember to set vim_markdown_preview_browser='firefox' in your vimrc.
HTH :)!
@pylipp a PR for firefox would be great!
@pylipp How can I test your version of the plugin using Vundle? I copied Plugin 'https://github.com/pylipp/vim-markdown-preview/tree/bugfix/firefox' into my plugin section at .vimrc but it won't install.
@Vitruvia Maybe this helps? I'm using vim-plug myself for plugin management.
@pylipp Thanks! Unfortunately, following the steps you pointed out didn't fix the issue for me.
Mmh a hack I can think of is to leave your vimrc untouched and go to the plugin directory instead (something like ~/.vim/bundle/vim-markdown-preview). There you add my fork as a new remote and checkout the firefox branch:
git remote add pylipp https://github.com/pylipp/vim-markdown-preview
git checkout -b bugfix/firefox pylipp/bugfix/firefox
Then you should be on the correct branch. However, this is probably going to be overwritten when you update the original plugin from within vim.
Dear friends,
Problem Solved, I missed the following setting:
let vim_markdown_preview_github=1
Many thanks!
Dear friends,
Although I've installed
- xdotool (version 3.+20171213.1),
- plugin via Vundle,
- replace the original .vim file in the bundle directory with pylipp's (for firefox),
the plug-in, yet, doesn't work. I am a bit frustrated. Could you be kind to lend me a hand? Any tip are highly appreciated.
➜ vim-markdown-preview git:(master) ✗ ls plugin README.md ➜ vim-markdown-preview git:(master) ✗ ls plugin applescript vim-markdown-preview.vim vim-markdown-preview.vim.bak ➜ vim-markdown-preview git:(master) ✗ xdotool --version xdotool version 3.+20171213.1 ➜ vim-markdown-preview git:(master) ✗ sudo update-alternatives --config x-www-browser [sudo] password for lh: There is only one alternative in link group x-www-browser (providing /usr/bin/x-www-browser): /usr/bin/firefox Nothing to configure. ➜ vim-markdown-preview git:(master) ✗ sudo update-alternatives --config gnome-www-browser There is only one alternative in link group gnome-www-browser (providing /usr/bin/gnome-www-browser): /usr/bin/firefox Nothing to configure. ➜ vim-markdown-preview git:(master) ✗ pwd /home/lh/.vim/bundle/vim-markdown-preview ➜ vim-markdown-preview git:(master) ✗ lsb_release -r Release: 14.04
@pylipp I also did not manage to use firefox with your modifications. In my init.vim I have
Plug 'pylipp/vim-markdown-preview', { 'branch': 'bugfix/firefox' }
let g:vim_markdown_preview_perl = 1
let g:vim_markdown_preview_browser = 'firefox'
Can you specify the system you are running?
Is the plugin installed correctly (can you check the installation folder and run git remote -v)?
Is see installed on your system and configured correctly (to use firefox as default browser - side note: this kinda makes the vim_markdown_preview_browser setting redundant, still have to change that on my branch)?
Is xdotool installed?
Does it work with a different browser?
Is it that your mapping does not work? What happens if you run :call Vim_Markdown_Preview() in an open markdown file?
Are you using NeoVim? I never tested the plugin or the firefox-branch there. Maybe that's an issue.
@pylipp One thing before I will answer. To which project exactly do you refer by see? Are we talking about the Python module or what? Google is not so helpful here.
see is a program provided by the mime-support package.
Can you manually open the html file generated by vim-markdown-preview with see /tmp/vim-markdown-preview.html?
I think this also requires a ~/.mailcap file with the contents like
text/html; /usr/bin/firefox %s; description=HTML Text; test=test -n "$DISPLAY"; nametemplate=%s.html
And maybe setting the environment variable $BROWSER=/usr/bin/firefox. Sorry for not being specific here, I think I once added a bunch of stuff to my system config and at some point it worked and has been ever since ;)... HTH!
@pylipp Well, but this is a Debian related package, and as I see it is an alias on mailcap. Cannot you simply drop see in favor of something standard like xdg-open? As I see Fedora still provides mailcap but right now it internally calls xdg-open, while openSUSE which I use does not provide anymore mailcap.
I set the vim-markdown-preview option to use xdg-open but then it does not really work as it should i.e., a new tab is open each time I want to refresh a markdown file preview.
Regarding the new tab being opened: Did the browser tab displaying the preview lose focus between two calls to Vim_Markdown_Preview()? xdotool is then unable to find the browser tab and asks the browser to open the preview html again, resulting in a new tab.
If you don't want to use xdg-open or mailcap, you could hardcode the browser executable in the source code.
I was able to get tabs refreshing on Ubuntu 16 with firefox with the following steps:
sudo apt install markdown xdotool- Launch the command below and make your browser's window active (just click on your browser after launching)
$ sleep 3; xdotool getwindowfocus getwindownameOutput:Opens new tab when called on Ubuntu 16 with firefox · Issue #68 · JamshedVesuna/vim-markdown-preview - Mozilla Firefox - Use the exact browser name in
.vimrclet vim_markdown_preview_browser='Mozilla Firefox'
@DmitrySandalov Thanks for investigating :) What version of firefox are you using? I think that makes a difference in how Firefox builds the tab title.
@pylipp
- Firefox 60.0, Build ID: 20180509235650,
dpkg -s: 60.0+build2-0ubuntu0.16.04.1 - xdotool version 3.20150503.1
- vim-markdown-preview [master 9b3ec41]
@DmitrySandalov let vim_markdown_preview_browser='Mozilla Firefox' is the key. (on master, with a recent version of firefox). This also makes #70 unnecessary. Though I can remember that back at that time my firefox was not appending 'Mozilla Firefox' to the browser tab title. Anyways I mostly use qutebrowser these days^^