Coder Social home page Coder Social logo

glow-hover.nvim's People

Contributors

jasonews avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

glow-hover.nvim's Issues

Implement smart_scroll functionality like that in lspsaga.nvim

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.

Ideas for improving readability

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:

Screenshot 2022-04-08 at 5 58 04 pm

glow-hover.nvim hover document:

image

{
  max_width = 500,
  padding = 1, 
  border = "rounded",
  glow_path = "glow",
}
  • Padding value seems to have no effect
  • Would be good if the doc was highlighted using nvim theme colors
  • Option to only render the documentation (not the signature) would also be pretty sweet
  • Opening the hover doc puts you into insert mode

Thanks!

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.