Browser Preview Works, but Webview Doesn't & Reports No Error
Describe the bug When I try the browser method it opens fine. When I try the webview preview nothing happens and no error displays at the bottom of nvim.
To Reproduce
- Install nvim (in my case compiled locally on a Pi4 because all the linux binaries and packages are for x86)
- Install Nvchad
- Install Deno, and Peek.nvim using the instructions from rocky linux: https://docs.rockylinux.org/books/nvchad/plugins/md_preview/
- Add the lines to the
lazy.luafile following: https://github.com/toppair/peek.nvim?tab=readme-ov-file#lazynvim - In order to get the browser view working I also needed to install xdg utils because I'm on a minimal install of Debian 12 Bookworm (back ported kernel 6.10)
Expected behavior
Before I installed the xdg-utils the space + op command would throw an xdg error, but then resolved after installation.
When I change the "browser" value to "webview" in my ~/.config/nvim/lua/plugins/init.lua file and run the same command nothing happens. No error.
Desktop (please complete the following information):
- OS: Debian 12
-
nvim --version: v0.10.3-dev-14+gfb5a0e28db
-
deno --version: 2.0.4
- plugin setup: ?
I don't really know how to give this better clarity. I'm fairly new to nvim and lua. Even just a hint where I could start looking, error logs somewhere, would be very helpful.
I have the same behavior: NVIM v0.10.2 deno 2.1.4 peek.nvim: 5820d937d5414baea5f586dc2a3d912a74636e5b
{
"toppair/peek.nvim",
event = { "VeryLazy" },
build = "deno task --quiet build:fast",
keys = {
{
"<leader>md",
function()
local peek = require("peek")
if peek.is_open() then
peek.close()
else
peek.open()
end
end,
desc = "Markdown Preview",
},
},
opts = {
-- Add this and it works with the browser:
-- app = "browser",
},
}
Personally solved it by installing webkit2gtk on Arch (cf. #61).
Also had to export WEBKIT_DISABLE_COMPOSITING_MODE=1 to avoid blank webview.
Personally solved it by installing
webkit2gtkon Arch (cf. #61).Also had to export
WEBKIT_DISABLE_COMPOSITING_MODE=1to avoid blank webview.
I wanted to give this a bump. I just installed peek and went through the preview not opening with 'webview'.
Exporting the environment variable and making sure webkit2gtk was installed did take care of it, however, as someone new trying this package none of this was clear from the README.
Update:
After reading some more, webkitgtk users of proprietary nvidia drivers breaks because of its new renderer. Exporting the environment variable fixes it in Arch linux for example, but distros like Ubuntu already include this change in their version of the package which is why some people aren't having this problem adding to the confusion.
I use both Nvidia and AMD gpus, as such, I added the following to my zshrc file:
if [[ -f /proc/driver/nvidia/version ]]; then
export WEBKIT_DISABLE_COMPOSITING_MODE=1
fi
This checks to see if nvidia proprietary drivers are actively running and sets the environment variable accordingly.
Same problem here. I just updated deno today and Lazy as well.
Debian 13.0 (trixie) NVIM v0.11.3 deno 2.4.5 (stable, release, x86_64-unknown-linux-gnu)
~/.config/nvim/lua/core/plugins/markdown/peek.lua:
return {
{
'toppair/peek.nvim',
event = { 'VeryLazy' },
build = 'deno task --quiet build:fast',
config = function()
require('peek').setup {
close_on_bdelete = true,
app = 'webview',
filetype = {
'markdown',
'vimwiki',
'vimwiki.markdown',
'vimwiki.markdown.pandoc',
},
}
vim.api.nvim_create_user_command('PeekOpen', require('peek').open, {})
vim.api.nvim_create_user_command('PeekClose', require('peek').close, {})
end,
opts = {},
},
}
~/.config/nvim/lua/core/keymaps.lua
vim.keymap.set('n', '<leader>md', ':PeekOpen<CR>')
vim.keymap.set('n', '<leader>mx', ':PeekClose<CR>')
webview has the aforementioned issue but browser works just fine. I've webkit2gtk already and in fish shell, I've run this to no effect:
set -Ux WEBKIT_DISABLE_COMPOSITING_MODE 1
What other details can I provide?
Thank you
If someone experiences the issue when webview doesn't run, check if your libwebkit2gtk is 4.0. In my case, the version was 4.1, which is not compatible with 0.7.6 version of webview the plugins uses.
Error
⚠️ The `--unstable` flag is deprecated and will be removed in Deno 2.0. Use granular `--unstable-*` flags instead.
Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags
⚠️ The `Deno.dlopen` API was used with `--unstable` flag. The `--unstable` flag is deprecated and will be removed in Deno 2.0. Use granular `--unstable-ffi` instead.
Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags
error: Uncaught (in promise) Error: Could not open library: Could not open library: libwebkit2gtk-4.0.so.37: cannot open shared object file: No such file or directory
return Deno.dlopen(await download(options), symbols);
^
at new DynamicLibrary (ext:deno_ffi/00_ffi.js:481:42)
at Object.dlopen (ext:deno_ffi/00_ffi.js:616:10)
at dlopen (file:///home/user/.local/share/nvim/lazy/peek.nvim/public/webview.js:1379:17)
at eventLoopTick (ext:core/01_core.js:168:7)
at async file:///home/user/.local/share/nvim/lazy/peek.nvim/public/webview.js:1424:13
The workaround for this issue:
- Change version in
webview.tsto0.9.0
import { Webview } from 'https://deno.land/x/[email protected]/mod.ts';
- Add
@denosaurs/plugdependency (seems to be a bug specific to newer versions)
deno add @denosaurs/plug
- Update cache
deno cache --reload app/src/webview.ts
- Rebuild the webview
deno task build:fast