[vim/vim] popup window keywordprg (Issue #16923)

26 views
Skip to first unread message

Enno

unread,
Mar 18, 2025, 1:47:50 AM3/18/25
to vim/vim, Subscribed

Replace the legacy &keywordprg commands using :term by system() calls showing up in below popup.

Just leaving here for reference. It's easy to do for programs showing a static single page help, say perldoc, go doc, ... Maybe a bit more involved for those navigating manpages.

asciicast

vim9script
# Shows popup window at cursor position
def ShowAtCursor(text: any, Setup: func(number) = null_function): number
    var new_text = text
    if text->type() == v:t_string
        new_text = text->trim("\<CR>")
    else
        new_text = text->mapnew((_, v) => v->trim("\<CR>"))
    endif
    var winid = popup_create(new_text, {
        padding: [0, 1, 0, 1],
        border: [],
        borderchars: popup_borderchars,
        borderhighlight: popup_borderhighlight,
        highlight: popup_highlight,
        pos: screencol() > &columns / 1.7 ? "botright" : "botleft",
        line: 'cursor-1',
        col: 'cursor',
        moved: 'WORD',
        mapping: 0,
        filter: (winid, key) => {
            if key == "\<Space>"
                win_execute(winid, "normal! \<C-d>\<C-d>")
                return true
            elseif key == "j"
                win_execute(winid, "normal! \<C-d>")
                return true
            elseif key == "k"
                win_execute(winid, "normal! \<C-u>")
                return true
            elseif key == "g"
                win_execute(winid, "normal! gg")
                return true
            elseif key == "G"
                win_execute(winid, "normal! G")
                return true
            endif
            if key == "\<ESC>"
                popup_close(winid)
                return true
            endif
            return true
        }
    })
    if Setup != null_function
        Setup(winid)
    endif
    return winid
enddef

def PopupHelp(symbol: string)
    ShowAtCursor(systemlist("go doc " .. symbol))
enddef

nnoremap <silent><buffer> K <scriptcmd>PopupHelp(expand("<cfile>"))<CR>

Originally posted by @habamax in #16911 (comment)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923@github.com>

KonfektKonfekt created an issue (vim/vim#16923)

Replace the legacy &keywordprg commands using :term by system() calls showing up in below popup.

Just leaving here for reference. It's easy to do for programs showing a static single page help, say perldoc, go doc, ... Maybe a bit more involved for those navigating manpages.

asciicast

vim9script
# Shows popup window at cursor position
def ShowAtCursor(text: any, Setup: func(number) = null_function): number
    var new_text = text
    if text->type() == v:t_string
        new_text = text->trim("\<CR>")
    else
        new_text = text->mapnew((_, v) => v->trim("\<CR>"))
    endif
    var winid = popup_create(new_text, {
        padding: [0, 1, 0, 1],
        border: [],
        borderchars: popup_borderchars,
        borderhighlight: popup_borderhighlight,
        highlight: popup_highlight,
        pos: screencol() > &columns / 1.7 ? "botright" : "botleft",
        line: 'cursor-1',
        col: 'cursor',
        moved: 'WORD',
        mapping: 0,
        filter: (winid, key) => {
            if key == "\<Space>"
                win_execute(winid, "normal! \<C-d>\<C-d>")
                return true
            elseif key == "j"
                win_execute(winid, "normal! \<C-d>")
                return true
            elseif key == "k"
                win_execute(winid, "normal! \<C-u>")
                return true
            elseif key == "g"
                win_execute(winid, "normal! gg")
                return true
            elseif key == "G"
                win_execute(winid, "normal! G")
                return true
            endif
            if key == "\<ESC>"
                popup_close(winid)
                return true
            endif
            return true
        }
    })
    if Setup != null_function
        Setup(winid)
    endif
    return winid
enddef

def PopupHelp(symbol: string)
    ShowAtCursor(systemlist("go doc " .. symbol))
enddef

nnoremap <silent><buffer> K <scriptcmd>PopupHelp(expand("<cfile>"))<CR>

Originally posted by @habamax in #16911 (comment)


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923@github.com>

Maxim Kim

unread,
Mar 18, 2025, 5:50:59 AM3/18/25
to vim/vim, Subscribed

It should have these defined as well (used in the function):

var popup_borderchars     = get(g:, "popup_borderchars", ['─', '│', '─', '│', '┌', '┐', '┘', '└'])
var popup_borderhighlight = get(g:, "popup_borderhighlight", ['Normal'])
var popup_highlight       = get(g:, "popup_highlight", 'Normal')

If there is a need I can add set of helper popup functions: https://github.com/habamax/.vim/blob/master/autoload/popup.vim#L1-L1

Or just a single one ShowAtCursor.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732382439@github.com>

habamaxhabamax left a comment (vim/vim#16923)

It should have these defined as well (used in the function):

var popup_borderchars     = get(g:, "popup_borderchars", ['─', '│', '─', '│', '┌', '┐', '┘', '└'])
var popup_borderhighlight = get(g:, "popup_borderhighlight", ['Normal'])
var popup_highlight       = get(g:, "popup_highlight", 'Normal')

If there is a need I can add set of helper popup functions: https://github.com/habamax/.vim/blob/master/autoload/popup.vim#L1-L1

Or just a single one ShowAtCursor.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732382439@github.com>

Maxim Kim

unread,
Mar 18, 2025, 5:55:27 AM3/18/25
to vim/vim, Subscribed

popup.Commands is useful to create a small popup with single key shortcuts: https://github.com/habamax/.vim/blob/master/autoload/popup.vim#L12-L26

asciicast


Reply to this email directly, view it on GitHub,.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732414264@github.com>

habamaxhabamax left a comment (vim/vim#16923)

popup.Commands is useful to create a small popup with single key shortcuts: https://github.com/habamax/.vim/blob/master/autoload/popup.vim#L12-L26

asciicast


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732414264@github.com>

Maxim Kim

unread,
Mar 18, 2025, 6:01:34 AM3/18/25
to vim/vim, Subscribed

popup.Select is useful to create popup with a list of thing to select from and do something with it: https://github.com/habamax/.vim/blob/master/autoload/popup.vim#L134-L169

vim-fzzy-basic.gif (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732455530@github.com>

habamaxhabamax left a comment (vim/vim#16923)

popup.Select is useful to create popup with a list of thing to select from and do something with it: https://github.com/habamax/.vim/blob/master/autoload/popup.vim#L134-L169

vim-fzzy-basic.gif (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732455530@github.com>

Maxim Kim

unread,
Mar 18, 2025, 6:03:09 AM3/18/25
to vim/vim, Subscribed

I am happy both to add it to dist/ it or not to add it :)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732467960@github.com>

habamaxhabamax left a comment (vim/vim#16923)

I am happy both to add it to dist/ it or not to add it :)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732467960@github.com>

Phạm Bình An

unread,
Mar 18, 2025, 6:08:12 AM3/18/25
to vim/vim, Subscribed

Just leaving here for reference. It's easy to do for programs showing a static single page help, say perldoc, go doc, ... Maybe a bit more involved for those navigating manpages.

What about just using popup-terminal?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732515659@github.com>

brianhusterbrianhuster left a comment (vim/vim#16923)

Just leaving here for reference. It's easy to do for programs showing a static single page help, say perldoc, go doc, ... Maybe a bit more involved for those navigating manpages.

What about just using popup-terminal?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/2732515659@github.com>

Phạm Bình An

unread,
Jul 8, 2025, 11:47:57 PM7/8/25
to vim/vim, Subscribed
brianhuster left a comment (vim/vim#16923)

I think popup window keywordprg would help with previewing a quickfix list entry, which should be very useful


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3051012215@github.com>

Enno

unread,
Jul 9, 2025, 3:47:53 PM7/9/25
to vim/vim, Subscribed
Konfekt left a comment (vim/vim#16923)

A quickfix list entry popup is useful, as these plug-ins testify, though seemingly already useful enough by previewing the surrounding lines of selected quickfix list entry, that is, the currently selected line in the quickfix list window. How would a popup window for a specific keyword in a quickfix list entry enhance that?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3053804824@github.com>

Phạm Bình An

unread,
Jul 10, 2025, 5:20:45 AM7/10/25
to vim/vim, Subscribed
brianhuster left a comment (vim/vim#16923)

How would a popup window for a specific keyword in a quickfix list entry enhance that?

It would still be a "preview current entry" command. Assigning it to 'keywordprg' is just to avoid remapping K


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3056509227@github.com>

D. Ben Knoble

unread,
Jul 10, 2025, 9:18:34 AM7/10/25
to vim/vim, Subscribed
benknoble left a comment (vim/vim#16923)

One really valuable thing about :terminal windows (or “normal” windows like from :Man or reading system outputs): I can navigate between then, yank and put text, and search them. I can also keep arrange them for reference while editing.

Popups lack much of this ability in their current incarnation as far as I can tell.

With that in mind, I still mostly prefer regular windows (although I do configure my LSP client to show popups!), so I want to decide which I use.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3057423659@github.com>

D. Ben Knoble

unread,
Jul 10, 2025, 9:20:02 AM7/10/25
to vim/vim, Subscribed
benknoble left a comment (vim/vim#16923)

popup.Commands is useful to create a small popup with single key shortcuts: https://github.com/habamax/.vim/blob/master/autoload/popup.vim#L12-L26

[asciicast

You may be interested in https://github.com/benknoble/popsikey


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3057430822@github.com>

Phạm Bình An

unread,
Jul 10, 2025, 12:49:13 PM7/10/25
to vim/vim, Subscribed
brianhuster left a comment (vim/vim#16923)

Popups lack much of this ability in their current incarnation as far as I can tell.

Then I think Vim popup should be improved, since Nvim's floatwin can do that easily. There is an issue tracking it #5639


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3058218070@github.com>

Enno

unread,
Jul 15, 2025, 3:53:37 AM7/15/25
to vim/vim, Subscribed
Konfekt left a comment (vim/vim#16923)

But

There is an explicit exception for a terminal in a popup

according to #7555 (comment)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3072503794@github.com>

dezza

unread,
11:11 AM (12 hours ago) 11:11 AM
to vim/vim, Subscribed
dezza left a comment (vim/vim#16923)

Popups lack much of this ability in their current incarnation as far as I can tell.

Another problem with popups is, if you don't messageopt-=hit-enter and messageopt+=wait:10000 and get a message/error while popup is visible;

popup/vim will appear stuck not responding to keys - when in reality behind the scenes its waiting for "ENTER" in the message window.

So save/restore &messageopt before display and in callback is how i fixed that. But its not obvious when you start using it.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3953191188@github.com>

Enno

unread,
2:15 PM (9 hours ago) 2:15 PM
to vim/vim, Subscribed
Konfekt left a comment (vim/vim#16923)

This deserves its own issue and needs fixture


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16923/3954208582@github.com>

Reply all
Reply to author
Forward
0 new messages