glow-hover.nvim
glow-hover.nvim copied to clipboard
breaks with new version of glow (1.5.0)
after updating my Archlinux and updating glow(1.4.1-3 => 1.5.0-1), This plugin kept giving me errors when i used lsp hover the second time after neovim opened (somehow the first time was always ok):
Error executing vim.schedule lua callback: ...ack/packer/start/glow-hover.nvim/lua/glow-hover/init.lua:146: 'width' key must be a positive Integer
stack traceback:
[C]: in function 'nvim_open_win'
...ack/packer/start/glow-hover.nvim/lua/glow-hover/init.lua:146: in function 'hovehandler'
...ack/packer/start/glow-hover.nvim/lua/glow-hover/init.lua:236: in function 'handler'
/usr/share/nvim/runtime/lua/vim/lsp.lua:1383: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
after some digging, found out that
-- lua/glow-hover/init.lua, line 199
local handle = io.popen(cmd)
local rendered = handle:read("*a") -- this returns empty string so width becomes zero
handle:close()
i tested same glow inputs outside of lua and it was fine and didn't give me empty results, but i don't know why in lua it keep giving empty results. downgrading glow also fixes the problem, but this will be a real problem for new users that wanna use this plugin.
I have the same problem here but thanks to @Arian8j2 i downgraded glow application on my Archlinux(btw) and now everything works fine 😋❤️
I got the same problem too, can this be fixed?
@SilverRainZ for now you can just downgrade the glow package to 1.4.1-3 version or older
fixed with replacing generation of renderedLines in init.lua:182:M.hovehandler
local renderedLines = vim.split(vim.fn.system(cmd), "\n", { plain = true })
Here is git diff
index 3822fa3..670d778 100644
--- a/lua/glow-hover/init.lua
+++ b/lua/glow-hover/init.lua
@@ -196,17 +196,9 @@ function M.hovehandler(markdown_lines, opts)
tf:flush()
local cmd = string.format("%s -w %d -s %s %s", opts.glow_path, opts.width,
colorscheme, tfn)
- local handle = io.popen(cmd)
- local rendered = handle:read("*a")
- handle:close()
+ local renderedLines = vim.split(vim.fn.system(cmd), "\n", { plain = true })
tf:close()
os.remove(tfn)
-
- local renderedLines = {}
- for line in rendered:gmatch("([^\n]*)\n?") do
- renderedLines[#renderedLines + 1] = line:gsub('%s+$', '')
- end
-
renderedLines = lsputil._trim(renderedLines)
opts = M.close_previous_previews(opts)
return M.open_floating_term(renderedLines, opts)```
@Shtsh Thanks, it works, I created a fork with your patch