markdown-preview.nvim
markdown-preview.nvim copied to clipboard
Retain neovim focus
Thanks for this phenomenal package! Is there any way to keep the window focus on nvim after opening a preview tab?
I have no idea how to do that.
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.
Got it. Helpful to know.
I am using i3wm on Linux with Firefox as default browser and the focus stays on
Neovim when calling :MarkdownPreview.
@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)
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.
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.
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?