markdown-preview.nvim icon indicating copy to clipboard operation
markdown-preview.nvim copied to clipboard

Retain neovim focus

Open benash opened this issue 5 years ago • 12 comments

Thanks for this phenomenal package! Is there any way to keep the window focus on nvim after opening a preview tab?

benash avatar May 05 '20 15:05 benash

I have no idea how to do that.

iamcco avatar May 06 '20 16:05 iamcco

Hi @benash , this relies on whether your browser exposes a functionality to open new tabs in background (by default, Firefox, Chrome, Edge don't) or play with Focus Stealing Prevention mechanism (if) exposed by your window manager.

I followed this for firefox and it works on my Windows and Linux machines.

@iamcco this can probably be closed as this has hard dependency of functionality exposed by browsers, not something this plugin can fix.

cpriyank avatar Aug 07 '20 01:08 cpriyank

Got it. Helpful to know.

benash avatar Aug 07 '20 01:08 benash

I am using i3wm on Linux with Firefox as default browser and the focus stays on Neovim when calling :MarkdownPreview.

ThomasFeher avatar Sep 27 '20 09:09 ThomasFeher

@ThomasFeher Really? How do you do it? I also have i3 and configured no_focus for firefox. This works when I call firefox from the terminal. But as soon as I call firefox google.com, the focus gets stolen by the website I'm providing the URL for. So it also does not work with markdown preview. I tried browser.tabs.loadDivertedInBackground, but no luck. Anything else you configured? Are you using the arch repos version of firefox? (Btw I'm using suckless surf now for the display, works great and is lightweight, can recommend! Still curious how to make it work with firefox)

bratekarate avatar Sep 27 '20 10:09 bratekarate

I am not aware of any special configuration, to be honest. I have Firefox running on a different workspace than my terminal. Calling firefox in the terminal opens a new window in the same workspace as the terminal and steals focus. Calling firefox google.com opens a new tab in the already open firefox (different workspace) and maintains focus on the terminal. browser.tabs.loadDivertedInBackground is false. I am running OpenSuse Tumbleweed with Firefox coming from the official OpenSuse Repo.

ThomasFeher avatar Sep 28 '20 19:09 ThomasFeher

Ok, nevermind. I am thinking about a different usecase. I have my workspace split into my vim instance and one browser instance for the markdown. I just use this firefox instance for the preview. With tabs in an existing browser it probably works.

bratekarate avatar Sep 28 '20 20:09 bratekarate

Hi, I also have a use case for this. Would it be possible to hook an xdotool script to focus nvim after starting the previewer?

DedZago avatar Nov 30 '22 09:11 DedZago