Skip to content

Latest commit

 

History

History
72 lines (55 loc) · 2.26 KB

README.md

File metadata and controls

72 lines (55 loc) · 2.26 KB

util to show popup for vim8 and neovim

if you like my work, check here for a list of my vim plugins, or buy me a coffee

Requirement

  • vim
    • exists('*popup_create')
  • neovim
    • exists('*nvim_open_win')
    • 0.7.0 or above, see this
      • you may let g:ZFPopup_nvim_enableOnOldVer=1 to bypass the check, but may cause E5601: Cannot close window, only floating window would remain

Install

use Vundle or any other plugin manager you like to install

Plugin 'ZSaberLv0/ZFVimPopup'
Plugin 'ZSaberLv0/ZFVimJob' " optional, recommeded to combine with this job utility

Usage

if ZFPopupAvailable()
    let popupId = ZFPopupCreate({
            \   'pos' : 'cursor|right|bottom',
            \ })
    call ZFPopupContent(popupId, ['line1', 'line2'])
    call ZFPopupClose(popupId)
endif

Functions

  • ZFPopupAvailable()

  • ZFPopupCreate([config])

    return popupId if success, or -1 if failed

    config: (default config can be configured by g:ZFPopup_defaultConfig)

    • pos : left/right/top/bottom/cursor, can combine as 'cursor|left|top', element order doesn't matter, default is right|bottom
    • width / height
      • [1, 9999) : use fixed size
      • (0.0, 1.0) : use size relative to screen size
      • others : use 1.0/4 and 5
    • x / y : offset according to pos
    • wrap : 0 or 1, whether :h wrap in popup window, default is 1
  • ZFPopupClose(popupId)

  • ZFPopupShow(popupId)

  • ZFPopupHide(popupId)

  • ZFPopupContent(popupId [, content])

    • when content not specified, return current content (as List of strings)
    • when content specified, set the entire content of popup buffer
  • ZFPopupConfig(popupId [, config])

    • when config not specified, return popup's config
    • when config specified, change and update popup's config
  • ZFPopupFrame(popupId) : return popup's window frame, as {'x':0,'y':0,'width':0,'height':0}

  • ZFPopupBufnr(popupId) : return popup's bufnr()

  • ZFPopupList() : return a List of popupId