jasonews / glow-hover.nvim Goto Github PK
View Code? Open in Web Editor NEWA Neovim plugin leveraging glow for LSPs hover responses.
License: Apache License 2.0
A Neovim plugin leveraging glow for LSPs hover responses.
License: Apache License 2.0
This plugin is great!
I've already replace my lspsaga.hover by this plugin.
but one thing I am missing is the smartscroll() in lspsaga.
Without smartscroll, I have to <C-w>w
to switch to float window
and use jk
to move and <C-w>w
to move back to previous window.
low efficiency!
My currrent workaround is
function M.scroll_in_float_win(move_step)
local windows = vim.api.nvim_list_wins()
for _, winid in ipairs(windows) do
-- the float window's relative is none,
-- then we can capture the float window
if vim.api.nvim_win_get_config(winid).relative ~= '' then
local bufid = vim.api.nvim_win_get_buf(winid)
local max_line_num = vim.api.nvim_buf_line_count(bufid)
local row_idx = vim.api.nvim_win_get_cursor(winid)[1]
local col_idx = vim.api.nvim_win_get_cursor(winid)[2]
if move_step < 0 then
-- upward moving
-- if the top visible line of the current window
-- is the first line, then don't do any move
row_idx = vim.fn.getwininfo(winid)[1].topline
if row_idx + move_step <= 0 then
break
end
-- set the cursor to the top visible line - 1
vim.api.nvim_win_set_cursor(winid, { row_idx + move_step, col_idx })
break
else
-- downward moving
-- if the bottom visible line of the current window
-- is the last line, then don't do any move
row_idx = vim.fn.getwininfo(winid)[1].botline
if row_idx + move_step > max_line_num then
break
end
-- set the cursor to the bottom visible line + 1
vim.api.nvim_win_set_cursor(winid, { row_idx + move_step, col_idx })
break
end
end
end
end
local keymap = vim.api.nvim_set_keymap
keymap('n', '<A-]>', [[<cmd>lua require('conf.move_tabs').scroll_in_float_win(1)<CR>]], { noremap = true })
keymap('n', '<A-[>', [[<cmd>lua require('conf.move_tabs').scroll_in_float_win(-1)<CR>]], { noremap = true })
This procedure works for any float window. And I believe that there will be only 1 float window when you are hovering so there won't be possible that you are scrolling another floating window simultaneously.
I would want to submit a PR, but I don't have time to dive deep into the code. I think we just need to keep track of the win_id of the floating window created by glow-hover and we are done.
Hi! love the idea of this & been looking for something like this for a while -- however there are a few readability issues / bugs that I think could be fixed:
Default hover document:
glow-hover.nvim
hover document:
{
max_width = 500,
padding = 1,
border = "rounded",
glow_path = "glow",
}
insert
modeThanks!
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.