iamcco / markdown-preview.nvim

markdown preview plugin for (neo)vim
MIT License
6.67k stars 277 forks source link

Struggling to open MarkdownPreview in Qutebrowser (flatpak version) #536

Open nguxx opened 1 year ago

nguxx commented 1 year ago

Hello,

Struggling to open MarkdownPreview in Qutebrowser (flatpak version) , I suppose it is because of the permissons i sould give to the sandbox of Qutebrowser. I've tried things like let g:mkdp_browser = 'flatpak\ run\ org.qutebrowser.qutebrowser' after a sudo flatpak override org.qutebrowser.qutebrowser --share=network without succes Would you have a hint ? Thanx

evdunbar commented 1 year ago

I am also having this issue but with a non-flatpak version of Qutebrowser. I have tried using this plugin with Firefox, Chromium, and now Qutebrowser, and only Firefox will display the page. Chromium and Qutebrowser both just load on white/blank pages forever.

My current command to open the browser I want is

function OpenMarkdownPreview(url)
    execute '!browser_of_choice' 'new_window_options' shellescape(a:url)
endfunction

but with browser_of_choice and new_window_options replaced with the appropriate commands for the different browsers.

Currently running on Neovim 0.9.1 on Void Linux.

sqwxl commented 7 months ago

I was having the same issue. Here's a solution that worked for me (using firefox, but should be similar with qutebrowser)

-- lazy.nvim
{
    "iamcco/markdown-preview.nvim",
    opts = function()
      local cmd
      -- check if flatpak command is available
      if vim.fn.executable("flatpak") == 1 then
        cmd = "flatpak firefox --new-tab"
      else
        -- check for running from container
        if vim.fn.executable("flatpak-spawn") == 1 then
          cmd = "flatpak-spawn --host flatpak run org.mozilla.firefox --new-tab"
        else
          -- native
          if vim.fn.executable("firefox") == 1 then
            cmd = "firefox --new-tab"
          else
            vim.notify("firefox not found", vim.log.levels.WARN)
          end
        end
      end
      vim.api.nvim_exec2(
        string.gsub(
          [[
        function MkdpBrowserFn(url)
          execute '!#' a:url
        endfunction
        ]],
          "#",
          cmd
        ),
        {}
      )
      vim.g.mkdp_browserfunc = "MkdpBrowserFn"
    end,
  }