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

Opens new tab when called on Ubuntu 16 with firefox #68

Open
Vitruvia opened this issue Aug 25, 2017 · 21 comments
Open

Opens new tab when called on Ubuntu 16 with firefox #68

Vitruvia opened this issue Aug 25, 2017 · 21 comments

Comments

@Vitruvia
Copy link

I have firefox as the standard browser (it is what came installed in the distro), and whenever I do a new tab opens. How can I fix this?

@JamshedVesuna
Copy link
Owner

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.

@Vitruvia
Copy link
Author

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 . Addionally, both in chrome and firefox my code blocks and bullet points don't render (they appear raw, as typed in the document).

@pylipp
Copy link

pylipp commented Aug 29, 2017

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 :)!

@JamshedVesuna
Copy link
Owner

@pylipp a PR for firefox would be great!

@Vitruvia
Copy link
Author

Vitruvia commented Aug 29, 2017

@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.

@pylipp
Copy link

pylipp commented Aug 30, 2017

@Vitruvia Maybe this helps? I'm using vim-plug myself for plugin management.

@Vitruvia
Copy link
Author

@pylipp Thanks!
Unfortunately, following the steps you pointed out didn't fix the issue for me.

@pylipp
Copy link

pylipp commented Sep 2, 2017

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.

@wow-meow-ai
Copy link

wow-meow-ai commented Dec 13, 2017

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

@copyme
Copy link

copyme commented Jan 29, 2018

@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'

@pylipp
Copy link

pylipp commented Jan 29, 2018

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?

@pylipp
Copy link

pylipp commented Jan 29, 2018

Are you using NeoVim? I never tested the plugin or the firefox-branch there. Maybe that's an issue.

@copyme
Copy link

copyme commented Jan 30, 2018

@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.

@pylipp
Copy link

pylipp commented Jan 30, 2018

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?

@pylipp
Copy link

pylipp commented Jan 30, 2018

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!

@copyme
Copy link

copyme commented Jan 31, 2018

@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.

@pylipp
Copy link

pylipp commented Feb 21, 2018

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.

@DmitrySandalov
Copy link

I was able to get tabs refreshing on Ubuntu 16 with firefox with the following steps:

  1. sudo apt install markdown xdotool
  2. Launch the command below and make your browser's window active (just click on your browser after launching)
    $ sleep 3; xdotool getwindowfocus getwindowname
    Output:
    Opens new tab when called on Ubuntu 16 with firefox · Issue #68 · JamshedVesuna/vim-markdown-preview - Mozilla Firefox
  3. Use the exact browser name in .vimrc
    let vim_markdown_preview_browser='Mozilla Firefox'

@pylipp
Copy link

pylipp commented May 15, 2018

@DmitrySandalov Thanks for investigating :) What version of firefox are you using? I think that makes a difference in how Firefox builds the tab title.

@DmitrySandalov
Copy link

@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]

@pylipp
Copy link

pylipp commented May 15, 2018

@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^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants