(text, line_offset)
Create a popup using Neovim 0.4+ floating windows.
Create a popup using Neovim 0.4+ floating windows.
Create a popup using Neovim 0 . 4 + floating windows .
def _neovim_popup(text, line_offset):
    """Create a popup using Neovim 0.4+ floating windows."""
    # Insert text into a scratch buffer
    buffer = vim.api.create_buf(False, True)
    vim.api.buf_set_lines(buffer, 0, -1, True, [f" {text} "])

    # Create a window containing the buffer
    window = vim.api.open_win(
        buffer,
        0,
        {
            "relative": "cursor",
            "row": int(line_offset),
            "col": 0,
            "style": "minimal",
            "focusable": 0,
            "height": 1,
            "width": len(text) + 2,
        },
    )
    # Set the highlight of the window to match the cursor
    vim.api.win_set_option(window, "winhl", "Normal:PathfinderPopup")

    # Create a timer to close the window
    popup_time = int(vim.vars["pf_popup_time"])
    vim.eval(f"timer_start({popup_time}, {{-> nvim_win_close({window.handle}, 1)}})")
def _neovim_popup ( text , line_offset ) : # Insert text into a scratch buffer buffer = vim . api . create_buf ( False , True ) vim . api . buf_set_lines ( buffer , 0 , - 1 , True , [ f" {text} " ] ) # Create a window containing the buffer window = vim . api . open_win ( buffer , 0 , { "relative" : "cursor" , "row" : int ( line_offset ) , "col" : 0 , "style" : "minimal" , "focusable" : 0 , "height" : 1 , "width" : len ( text ) + 2 , } , ) # Set the highlight of the window to match the cursor vim . api . win_set_option ( window , "winhl" , "Normal:PathfinderPopup" ) # Create a timer to close the window popup_time = int ( vim . vars [ "pf_popup_time" ] ) vim . eval ( f"timer_start({popup_time}, {{-> nvim_win_close({window.handle}, 1)}})" )