stsewd / gx-extended.vim

Extend gx to use it beyond just URLs!
MIT License
44 stars 6 forks source link

gx freezes vim if browser is not already open #2

Open astier opened 3 years ago

astier commented 3 years ago

System

Problem

If the browser is not already open and gx is used to open a link then the browser opens with the correct site, however vim freezes until the browser is closed. If the browser is already open before executing gx then it works as expected and vim doesn't freeze.

vimrc

cal plug#begin($XDG_DATA_HOME.'/nvim/plugins')
    Plug 'stsewd/gx-extended.vim'
cal plug#end()

Reproduce

  1. Close browser
  2. Open vimrc with vim
  3. Move cursor over Plug 'stsewd/gx-extended.vim'
  4. Type gx
stsewd commented 3 years ago

Hi, what OS are you using? I'm not able to replicate it with fedora 34. Also, does this also happens when using the default gx implementation (without this plugin press gx over a full url like https://github.com)

astier commented 3 years ago

Arch Linux. Native gx doesn't work. I set let g:netrw_browsex_viewer= "xdg-open". It tries do download something. Opens a new buffer. Sometimes it shows the download url in the browser but its not the proper website.

Opening the same website with xdg-open from the terminal works.

astier commented 3 years ago

If no firefox window is open and I try to open a website with firefox from the terminal than also firefox doesn't go to the background in the terminal. Basically the terminal 'hangs' with firefox (I don't know the proper terminology) until I press which frees the terminal but also closes the browser.

If a firefox-window is already open than the website simply opens up in a new tab in the already existing firefox-window.

Can it be that you have some kind of firefox-deamon running in the background? Could you reproduce it in the terminal?

divramod commented 2 years ago

hey @astier, you found a solution to your problem?

astier commented 2 years ago

No.

UnkwUsr commented 6 months ago

I made hacky solution:

let g:gxext#opencmd = '/bin/sh -c "your-browser \"\$1\" & disown" sh'

(replace your-browser with your browser name)

How it works: main thing to make browser starting in background is & disown part. But as plugin expands opencmd variable into <opencmd> <url>, we needed to make such opencmd command which accepts url as very latest argument (because we have no placeholders like %s in C, if you know...). So here is /bin/sh -c ... hack.